Dwr WebContextFactory.get() null 问题
来源:互联网 发布:知迷途其未远 编辑:程序博客网 时间:2024/06/14 09:47
由于项目是用DWR3 + SPRING + EXTJS 组建,所以有些地方用到了SERVLET,用户登录成功后就将用户的信息放在SESSION中,在其它地方直接用WebContextFactory.get().getSession().getAttribute("USER");来获取当前用户信息。只有一个SERVLET时,没有问题,但是当一个同事为了下载功能又写了一个SERVLET。问题出现了!即用WebContextFactory.get().getSession().getAttribute("USER");会直接报错,NULL类型错误。
查了半天,个人理解应该是每个SERVLET会产生不同的上下文,但是DWR的WebContextFactory.get()并不能自动增加另一下上下文。
查了DWR3的源码,WebContextFactory.get()是WebContextBuilder提供的,于是想直接通过创建WebContextBuilder来完成这两个SERVLET的联系。代码如下:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ServerContext sc = ServerContextFactory.get();// DWR的上下文
WebContextBuilder webBuilder = new DefaultWebContextBuilder();// 创建WebContextBuilder
webBuilder.engageThread(sc.getContainer(), request, response);// Make the current thread know what the current request is
......
}
- Dwr WebContextFactory.get() null 问题
- dwr WebContextFactory 工厂模式
- dwr WebContextFactory 工厂模式
- DWR框架中WebContext与WebContextFactory类
- dwr通过WebContextFactory获取请求对象
- 关于DWR中WebContextFactory的测试(学习中ing~~~~)
- DWR问题
- DWR问题
- Jquery $.ajax $.post $.get 异步请求 return undefined null问题
- map 之 get null
- Field.get(null)
- dwr路径问题
- dwr问题请教
- DWR同步异步问题
- ssh + dwr 问题
- DWR【option赋值问题】
- dwr日期问题
- dwr+ibatis 问题集
- Partitioned Tables
- (ZZ)xampp搭建php服务器下创建数据库图文详解
- IHttpModule与IHttpHandler的区别整理
- jquery ui中文说明(使用方法)
- 常用URL
- Dwr WebContextFactory.get() null 问题
- INDIRECT函数应用失败的实例分析及解决
- SQL注入攻击与防御
- AdvancedDataGrid是按数据添加到它的DataProvider的顺序显示数据
- (ZZ)xampp搭建的php服务器安装discuz论坛图文全解
- 旦复携手甲骨文推出面向数据库OCP认证的 ORACLE 360学习计划
- 上传图片并生成缩略图的一个方法
- C# 中的委托和事件
- linux logo 的启动方式