***************1.[一般推荐使用](只能获得request,而response则得不到)**********************
- ActionContext.getContext().put("liuwei", "andy"); //request.setAttribute("liuwei", "andy");
- Map map=ActionContext.getContext().getSession(); //session
- map.put("username", "name");
- HttpServletRequest request = ServletActionContext.getRequest();
- HttpServletResponse response = ServletActionContext.getResponse();
- request.getSession().setAttribute("username","liuwei");
- request.setAttribute("pass", "132");
继承 implements ServletRequestAware
类中申明:private HttpServletRequest request;
实现接口的方法:
- public void setServletRequest(HttpServletRequest request)
- {
- this.request = request;
- }