四种方式:
1.创建request,session,application Map对象
request=(Map)ActionContext.getContext().get("request");
session=ActionContext.getContext().getSession();
application=ActionContext.getContext().getApplication();
2.实现RequestAware,SessionAware,ApplicationAware接口
实现这三个接口,采取容器注入的方式:
在Action类中声明这三个对象
private Map<String,Object> request;
private Map<String,Object> session;
private Map<String,Object> applicaton;
3.创建传统的HttpServletRequest,HttpSsesion,ServletContext;
创建传统的HttpServletRequest,HttpSession,HttpServletConext;
在Action类中创建
private HttpServletRequest request;
private HttpSession session;
private ServletContext application;
request=ServletActionContext.getRequest();
session=request.getSession();
application=session.getServletContext();
4.实现ServletRequestAware,ServletContextAware接口
同样也是采用IOC容器注入。