ActionContext(用new ThreadLocal()邦定了线程)
| |--ServletActionContextpublic class ContextAction extends ActionSupport { public String test(){ //获取request对象 HttpServletRequest request=ServletActionContext.getRequest(); request.setAttribute("username", "username_request"); //获取response对象 HttpServletResponse response=ServletActionContext.getResponse(); //获取session对象 Mapsession=ServletActionContext.getContext().getSession(); session.put("username", "username_session"); //获取ServletContext对象 ServletContext sc=ServletActionContext.getServletContext(); sc.setAttribute("username", "username_application"); return "text"; } }