在struts中使用request、session、application对象时怎样生成此对象。
下面有两种方式生成,第一种于servlet耦合性不高,也比较适合在struts中使用的常态代码如下:
ActionContext cox=ActionContext.getContext();
Map<String,Object> se=cox.getSession();
Map<String, Object> ap=cox.getApplication();
Map<String,Object> req=(Map<String,Object>)cox.get("requset");
下面这一种是与servlet中生成的对象没有区别是原生态的生成方法,不推荐使用。
HttpServletRequest reqt=ServletActionContext.getRequest();
HttpSession session=reqt.getSession();
ServletContext appliction=reqt.getServletContext();