thymeleaf依赖以及一些图片、文件、cdn的导入问题

导入依赖

<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
<html lang="en" xmlns:th="htttp://www.thymeleaf.org">

使用thymeleaf之前记得加上xmlns以及里面的内容 否则所有thymeleaf都不生效

导入本地文件包括jsc、ss、img、都需要在前面加上th:src然后用@{}把整个路劲包起来 link则在href中加th类似

<script type="text/javascript" th:src="@{../static/js/jquery-3.3.1.js}"></script>
<link th:href="@{/myuser/css/bootstrap.min.css}" rel="stylesheet">

文本:th:text转义字符  即里面内容的标签内容,th:utext不转义字符

数组:<h3 th:each ="user:${user}" th:text="{$user}"></h3>

 使用<p th:text="${msg}" th:if="${not #string.isEmoty{msg}}"></p>  可以让标签在msg为空的时候不显示这个<p>标签这个里面的msg是在之前controller里面判断密码错误之后才赋值的。

原文地址:https://www.cnblogs.com/itwxx/p/11980882.html