后臺代碼:@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>
SpringBoot,Thymeleaf th:text=${name}獲取不到后端傳過來的值
臨摹微笑
2018-09-04 09:09:23