【发布时间】:2017-05-13 19:27:17
【问题描述】:
我已经定义了我的对象
@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class MySession {
private String message;
// getter setter
}
当我尝试从 thymeleaf 访问时失败了。
<p th:text="${mySession.message}"></p>
解决方案
通过spring bean访问
http://www.thymeleaf.org/doc/articles/springmvcaccessdata.html
<p th:text="${@mySession.getMessage()}"></p>
【问题讨论】:
-
什么失败了?有什么错误吗?
-
错误消息:在 null 上找不到属性或字段“消息”。但是,我找到了解决方案,通过 spring bean 访问
标签: spring-mvc spring-boot thymeleaf