【发布时间】:2017-11-08 13:49:06
【问题描述】:
我尝试过以这种方式访问变量:
<p th:text="${#session.getAttribute('mySessionAttribute')}"></p>
@RequestMapping({"/"})
String index(HttpSession session) {
session.setAttribute("mySessionAttribute", "someValue");
return "index";
}
文档说:#session:直接访问与当前请求关联的 javax.servlet.http.HttpSession 对象。
我正在使用 Tomcat 8、Java 8、Spring Boot 和 Thymeleaf。
【问题讨论】:
-
您好,欢迎来到 StackOverflow。请花一些时间阅读帮助页面,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。更重要的是,请阅读the Stack Overflow question checklist。您可能还想了解Minimal, Complete, and Verifiable Examples。
-
@RivanLuiz This 就是你要找的东西
-
@Metroids 的答案更合适。谢谢。
标签: spring spring-boot thymeleaf