Thymeleaf语法及使用
Thymeleaf使用:
		1.依赖:
<dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring5</artifactId> </dependency> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-java8time</artifactId> </dependency>
		2.在页面加入约束:<html xmlns:th="http://www.thymeleaf.org">
		3.所有的html元素都可以呗Thymeleaf接管:th: 元素名(<div th: text="${msg}"></div>)
取用各种数据的表达式:
普通变量:${...}
国际化消息:#{...}
URL消息:@{...}
片段表达式:~{...}
选择变量信息: *{...}

each:
th:each="遍历出的个体:${集合名} "
<h3 th:each="user:${users}" th:text="${user}"></h3> <!--或者--> <h3 th:each="user:${users}" >[[${user}]]</h3>

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号