struts2访问servlet api

 

   

Map request = (Map)ActionContext.getContext().get("request");
Map<String, Object> session = ActionContext.getContext().getSession();

 

 

public class TestAction implements RequestAware,SessionAware {
	private Map<String, Object> request;
	private Map<String, Object> session;

	@Override
	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
}

 

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

 

 

 

 

 

你可能感兴趣的:(struts2访问servlet api)