使用HTML页面时用Thymeleaf拿不到后端传回Model的值,经过测试jsp页面用el表达式可以拿到。请帮我看看问题在哪里?谢谢
后端SSM的Controller代码
@RequestMapping("/test")
public String test(Model m){
int cid=2010002;
String test="<h1>测试!<h1>";
m.addAttribute("test",test);
return "/text2.html";
}
前端HTML页面
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title th>Title</title>
</head>
<body>
<p th:utext=${test} id="test"></p>
<p th:utext=${param.test} id="test1"></p>
<p th:text=${test} ></p>
<p th:text=${param.test} ></p>
</body>
</html>
前端访问后一片空白。啥也没有。我也用过jsp页面测试el表达式可以拿到
缺少双引号
<p th:utext="${test}" id="test"></p>