zoukankan      html  css  js  c++  java
  • SpringBoot---基本配置

    1、首先在pom.xml添加对HTML的相关依赖

    /**
     * pom.xml文件
     */
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>**

    2、在application.yml文件添加SpringBoot相关配置

    spring:

      thymeleaf:
        prefix: classpath:/templates/

    注意:application.yml 如果是空文件,则默认视图文件存放在
    templates文件下,资源文件存放在static目录下,由于SpringBoot对jsp支持不太友好,一般使用自带的标签实现数据的赋值



    在Controller里面写跳转HTML页面方法

    @Controller  //注意这里必须为Controller
    public class HelloController {
    
        /**
         * 本地访问内容地址 :http://localhost:8080/lmycc/hello
         * @param map 传递参数
         * @return
         */
        @RequestMapping("/hello")
        public String helloHtml(HashMap<String, Object> map) {
            map.put("hello", "欢迎进入HTML页面");
            return "/index";
        }
    }
  • 相关阅读:
    Vue项目中使用Vue-Quill-Editor富文本编辑器插件
    Element-UI中的Cascader 级联选择器高度以及位置问题
    Sublime中同一个文件进行分屏显示
    Oracle的clob数据类型
    查看Nginx版本号的几种方式
    华为路由器EasyNAT&NAT Server
    huawei路由器NAT配置
    15
    14
    13
  • 原文地址:https://www.cnblogs.com/csguo/p/9597124.html
Copyright © 2011-2022 走看看