第一种方式///
Map类型:
利用ActionContext,返回Map类型//
//先获得ActionContext对象
ActionContext context=ActionContext.getContext();
Map<String,Object> session=context.getSession();
session.put("username","scott");
Map<String,Object> request=(Map)context.get("request");
Map<String,Object> app=context.getApplication();
Servlet使用类型:
ServletActionContext返回的是Servlet使用类型//
//现获得ServletActionContext.getRequest()
HttpServletRequest httpreq=ServletActionContext.getRequest();
HttpSession httpsession =httpreq.getSession();
ServletContext httpapp=ServletActionContext.getServletContext();
第二种方式///
Map类型:
将Action实现Aware接口,由框架底层将对象注入给Action的变量
RequestAware接口:Map类型的request
SessionAware接口:Map类型的session
ApplicationAware接口:Map类型的application
http类型:
ServletRequestAwre接口:http类型的request
ServletResponseAware接口:http类型的response
ServletContextAware接口:http类型的application