在使用Freemarker作为View的时候,没有自动将session传送至页面使用,原因很简单,为了遵 循restful。如果在项目中使用了session,那么集群就不太方便了,需要想办法对session进行同步才可以。所以JFinal默认是不会去 生成session对象让开发者去使用的。
1. 在JFinalConfig的继承类中添加了SessionInViewInterceptor
public void configInterceptor(Interceptors interceptor) { interceptor.add(new SessionInViewInterceptor()); }
2、html页面el表达式取值方式:${session['userInfo'].username}