2017-07-20 11:41
@macaque 拦截器里面做是不会生效的,因为拦截器只拦截 action,不拦截 render
最好的做法是类似于如下:
public class MyTemplateRender extends TemplateRender {
static ThreadLocal threadLocal = new ThreadLocal();
public MyTemplateRender(String view) {
super(view);
}
public void render() {
threadLocal.set(...);
try {
super.render();
} finally {
threadLocal.remove();
}
}
然后通过扩展 RenderFactory 来切换自己的 MyTemplateRender:
public class MyRenderFactory extends RenderFactory {
public Render getRender(String view) {
render new MyTemplateRender(view);
}
}
最后配置一下:
me.setRenderFactory(new MyRenderFactory());
2017-07-20 00:38
@rancedxk 这里的细节我也不记得了,在本地搭建一个测试环境,现场调试一下,搭建方法在此:
http://git.oschina.net/jfinal/jfinal-weixin/wikis/JFinal-weixin-demo%E5%92%8C%E8%B0%83%E8%AF%95