SpringBoot,Thymeleaf th:text=${name}获取不到后端传过来的值

后台代码:
@Controller // 标明这是一个SpringMVC的Controller控制器
@RequestMapping("/syj")
public class TestJspController {

@RequestMapping("/helloa")
public ModelAndView gg2(ModelAndView mv,HttpServletRequest request,HttpSession session ){
session.setAttribute("kk", "金合欢花或或");
request.setAttribute("key", "神学集团克东");
mv.setViewName("home/aaa");
mv.addObject("title","欢迎使用Thymeleaf!");
return mv;
}
前台:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
<title>Good Thymes Virtual Grocery</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
<div th:text="${session.kk}">测试session</div>
<h1 th:inline="text" >
<p th:text="${key}" th:remove="tag">Welcome to our grocery store!</p>
</h1>

<p th:text="${title}">Welcome to our grocery store!</p>

<h1>
<span th:text="${key}" th:remove="tag">title</span>
<small th:text="${key}" >Subtitle</small>
</h1>

</body>


临摹微笑
浏览 16177回答 1
1回答

慕的地8271018

你的前台文件没有,th:text=${name}是不是写错了?
打开App,查看更多内容
随时随地看视频慕课网APP