获得request、response对象的三种方法
方法一
//struts获取方法
// HttpServletRequest request = ServletActionContext.getRequest();
// HttpServletResponse response = ServletActionContext.getResponse();
方法二
//SpringMvc获取方法
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletResponse response =((ServletWebRequest)RequestContextHolder.getRequestAttributes()).getResponse();
方法三
//获得request、response对象:
ActionContext ctq= ActionContext.getContext();
HttpServletResponse responses=(HttpServletResponse )ctq.get(ServletActionContext.HTTP_RESPONSE);
ActionContext ct= ActionContext.getContext();
HttpServletRequest requests=(HttpServletRequest)ct.get(ServletActionContext.HTTP_REQUEST);