spring-boot

引入springboot的依赖

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

引入thymeleaf模板引擎依赖

<dependency>
   <groupId>org.thymeleaf</groupId>
   <artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
   <groupId>org.thymeleaf.extras</groupId>
   <artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
在html 引入 xmlns:th="http://www.thymeleaf.org"
url使用@{...}
例如:
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">

 

 

 



springboot-thymeleaf用法

controller传参
        model.addAttribute("msg","hello1111111111111");
        model.addAttribute("hero", Arrays.asList("老李","老李1","老李2"));
前端接收
    <div th:text="${msg}"></div>
    <div th:each="A:${hero}"  th:text="${A}"></div>

  

 

posted @ 2021-04-26 15:06  丶恍惚  阅读(50)  评论(5)    收藏  举报