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";
        }
    }
  • 相关阅读:
    十、 Spring Boot Shiro 权限管理
    十六、Spring Boot 部署与服务配置
    十五、Spring Boot 环境变量读取 和 属性对象的绑定
    三、spring cloud 服务提供与调用
    CSS 表格实例
    CSS 列表实例
    CSS 内边距 (padding) 实例
    CSS 外边距
    CSS 边框(border)实例
    CSS 字体(font)实例
  • 原文地址:https://www.cnblogs.com/csguo/p/9597124.html
Copyright © 2011-2022 走看看