struts2中获得request方法

request:

		ValueStack request = ActionContext.getContext().getValueStack();
		
		HttpServletRequest request = ServletActionContext.getRequest();
		
		HttpServletRequest request = (HttpServletRequest)ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);

 

session:

Java代码 复制代码
  1. HttpSession session = ServletActionContext.getRequest().getSession();      
  2. HttpSession session = (HttpSession)ActionContext.getContext().get(ServletActionContext.SESSION);  
  3. Map map = (Map)ActionContext.getContext().getSession();  


其中:org.apache.struts2.ServletActionContext作为辅助类(Helper Class)可以快速获得

你可能感兴趣的:(java,apache)