struts2 Action中获取request, response对象

ActionContext ctx = ActionContext.getContext();        
       
HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);        
       
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);        


标准做法应该是action implements RequestAware

你可能感兴趣的:(java)