使用thymeleaf,跳转到对应页面,但是没有在页面上显示对应的数据
@Controller public class HelloWorldController { @RequestMapping("success") public String success(Map<String,Object> map) { map.put("hello","你好"); return"success"; } }
模版为:
<!DOCTYPE html>
<!--为了语法提示 xmlns:th="http://www.thymeleaf.org"-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Success</title>
</head>
<body>
成功
<!--th:text 将div里面的内容设置为-->
<div th:text="${hello}">
这里显示欢迎信息
</div>
</body>
</html>
在这里切记:不能使用@RestController这个注解。因为这个注解使用流的形式进行返回数据。
本文来自博客园,作者:King-DA,转载请注明原文链接:https://www.cnblogs.com/qingmuchuanqi48/p/13214549.html

浙公网安备 33010602011771号