在Action中获取request、response、session对象

HttpServletRequest request = ServletActionContext.getRequest();    
HttpServletResponse response = ServletActionContext.getResponse();    
HttpSession session = request.getSession();

ActionContext ctx = ActionContext.getContext();    
Map session = ctx.getSession();
这里的session是个map对象在Struts2中底层的session都被封装成了Map类型我们可以直接操作这个map 进行对session的写入和读取操作而不用去直接操作HttpSession对象

猜你喜欢

转载自chenzheng8975.iteye.com/blog/1915210