Thymeleaf和会议

时间:2013-06-05 08:41:20

标签: java spring session spring-mvc thymeleaf

1)谁知道请提供有关使用Thymeleaf模板引擎的页面中的会话的更多信息。

2)默认会话在Thymeleaf中启用,就像在JSP?

中一样

3)在Thymeleaf中,会话对象有任何限制吗?

4)在Thymeleaf中有(或需要)一些特定的结构来处理会话吗?

在JSP中我们默认使用session =“true”,我们必须使用这样的东西:

<jsp:directive.page contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" session="false" />

谷歌或Thymeleaf论坛没有足够的信息来说明这个模板引擎如何使用会话。

我的英语基础水平。

3 个答案:

答案 0 :(得分:4)

使用#httpSession或$ {session} Object及其方法来检查ServletSession。请确保您使用ExpressionLanguage进行所有操作。

Click Here了解更多信息。

答案 1 :(得分:1)

Thymeleaf是一个模板引擎,也可以选择(尽管最常用)作为Spring MVC中的视图层。作为模板引擎,它与会话没有任何关系。它的工作只是处理EL并吐出标记。

另一方面,Spring MVC将允许会话bean范围,并且可以让您访问和修改会话。见http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html

另见: Spring MVC: HTTP session management "equivalent" Spring "session" scope of a bean

答案 2 :(得分:0)

您可以轻松地与百里香一起使用会话。

   session.setAttribute("mySessionAttribute", "someValue");

您可以访问直接会话属性。

${#session.getAttribute('mySessionAttribute')}