struts中request、session、application對象的生成

在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();

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章