Thymeleaf 常见属性中th:text和th:utext的区别
控制台代码:
public String login1(Model m) {
String text="<h1 style=\"color:red\">这里是th:text</h1>";
String utext="<h1 style=\"color:red\">这里是th:utext</h1>";
m.addAttribute("text",text);
m.addAttribute("utext",utext);
return "login";
}
th:text
如果是需要从model中取值的话 html的写法为th:text=“${model的name}”
<div><p th:text="${text}"></p></div>
如果是需要字符串与model中的值进行拼接的话,写法为th:text=“‘字符串’+${model的name}”
使用的是加号(+)