2
我定义我的对象如何进入春季会话bean范围,thymeleaf
@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class MySession {
private String message;
// getter setter
}
当我尝试从thymeleaf未能访问。
<p th:text="${mySession.message}"></p>
SOLUTION
通过访问Spring bean的
http://www.thymeleaf.org/doc/articles/springmvcaccessdata.html
<p th:text="${@mySession.getMessage()}"></p>
什么是失败?有什么错误? – Patrick
错误消息:无法在null上找到属性或字段“消息”。但是,我发现了解决方案,通过春豆访问 – prptn