1.Controller类里的方法
@RequestMapping("/success")
public String success(Map<String,Object> map){
map.put("hello","<h1>你好</h1>");
//map.put("user");
map.put("users", Arrays.asList("hj","cyw"));
return "success";
}
2.success.html里的内容
<!DOCTYPE html >
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>成功</h1>
<!-- 静态的东西会被动态的覆盖 -->
<!-- text不会转义特殊标签 utext会-->
<div th:text="${hello}">这里显示欢迎信息</div>
<div th:utext="${hello}"></div>
<!-- each可以循环遍历 -->
<h2 th:text="${user}" th:each="user:${users}"></h2>
</body>
</html>