后台代码:
@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>
慕的地8271018