struts框架学习二 action对jsp传值
作者:互联网
action
HttpServletRequest、HttpSession和ServletContext
Struts2对这个三个对象用Map进行了封装,我们就可以使用Map对象来存取数据了。
ActionContext actionContext = ActionContext.getContext(); //get HttpServletRequest Map<String,Object> request = (Map) actionContext.get("request"); request.put("a", "a is in request"); //get HttpSession //Map<String,Object> session = (Map) actionContext.get("session"); Map<String,Object> session = actionContext.getSession(); session.put("b", "b is in session"); //get ServletContext //Map<String,Object> application = (Map) actionContext.get("application"); Map<String,Object> application = actionContext.getApplication(); application.put("c", "c is in application");
jsp界面
${a} ${b} ${c} 或则request.getAttribute("a"); session.getAttribute("b); application.getAttribute("c");
标签:Map,get,struts,request,application,session,jsp,action,actionContext 来源: https://www.cnblogs.com/zlj843767688/p/12626906.html