标签:style blog http color os 数据 io art
第一种:获取requestMap,sessionMap,applicationMap, HttpServletRequest,HttpServletResponse对象的获取,在Struts2中
1 public String getMap(){ 2 //获取被处理过的request,session,application三大常用作用域的map形式,可以往里边存放数据,在jsp中就可以用el,ognl表达式取值 3 //ac容器在struts2中任何地方都可以获取,可以当做一个作用域来传递值 4 ActionContext ac=ActionContext.getContext(); 5 //requestMap 6 Map<String, Object> requestMap=(Map<String, Object>) ac.get("request"); 7 //sessionMap 8 Map<String, Object> sessionMap=ac.getSession(); 9 //applicationMap 10 Map<String, Object> applicationMap=ac.getApplication(); 11 12 13 //获取真正的request,session,application,response对象 14 15 //httpServletRequest 常用于一次请求传递数据 16 HttpServletRequest request=ServletActionContext.getRequest(); 17 //httpServletResponse,常用于ajax请求响应 18 HttpServletResponse response=ServletActionContext.getResponse(); 19 //ac容器 20 ActionContext ac1=ServletActionContext.getContext(); 21 return null; 22 }
Struts2重学习之作用域的获取,布布扣,bubuko.com
标签:style blog http color os 数据 io art
原文地址:http://www.cnblogs.com/shangxiaofei/p/3866052.html