This page last changed on Nov 30, 2004 by jcarreira.
Webwork provides several access helpers to access Session, Application, Request scopes.
Web agnostic (independent of the servlet API) with calls:
Map session = (Map) ActionContext.getContext().get("session");
session.put("myId",myProp);
The following gives you the same thing as above:
ServletActionContext.getRequest().getSession()
Note: Be sure not to use ActionContext.getContext() in the constructor of your action since the values may not be set up already (returning null for getSession()).
Note also: ActionContext.getContext().get("session") is the same as
ActionContext.getContext().getSession() with a cast to Map.
If you really need to get access to the HttpSession, use the ServletConfigInterceptor (see
Interceptors).
In your views, you can access with your jsps as such
"#session.myId" />
"#request.myId" />
All the servlet scopes can be accessed like above.
Map request = (Map) ActionContext.getContext().get("request");
request.put("myId",myProp);
Map application = (Map) ActionContext.getContext().get("application");
application.put("myId",myProp);
Map session = (Map) ActionContext.getContext().get("attr");
attr.put("myId",myProp);
The 'attr' map will search the javax.servlet.jsp.PageContext for the specified key. If the PageContext dosen't exist, it will search request,session,application maps respectively.
Application, Session, Request objects in jsp
This page last changed on Nov 30, 2004 by jcarreira.
The application, session and request objects are available from within ww tags in jsp wherever ognl can be evaluated. Use the #session syntax to get the object and access values by their keys using ['key'].
<ww:property class="java-quote" value="&lt;span">"#application['foo']"/>
<ww:property class="java-quote" value="&lt;span">"#session['baz']"/></ww:property></ww:property>
Conversely, if you would like to make webwork objects availible to say the jsp/jstl request scope. The property tag can be used like this.
<ww:set class="java-quote" name="&lt;span">"jobz" value="jobs" scope="request" /></ww:set>
A full example below shows a webwork variable "jobs" being exposed as "jobz" and being used with jstl and the display tag.
WW:Exposing webwork objects to JSTL, with a JSTL and DisplayTag Example
分享到:
相关推荐
jta-1.0.1.jar
WebWork深入浅出.doc webwork开发指南中文版
webwork.doc,开发说明
webwork的讲解,详细的讲解了webwork的工作原理 还有例子可供参考
webwork,用于生成doc文档,更好的让您工作顺利进行!
webwork in action 中文版
包含Webwork2 Guide 电子书 和webwork2doc_zh1[1]电子书
Struts 2 技术详解:基于WebWork核心的MVC开发与实践
webwork Spring hibernate整合配置.doc
WebWork完全教程 java
webwork-2.2.7_api_doc,chm webwork-2.2.7_api_doc,chm
WEBWORK的配置
webwork中上传文件,webwork文件上传.doc
webwork操作一些基本东西
webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程webwork教程
WEBWORK的源文件压缩包WEBWORK的源文件压缩包WEBWORK的源文件压缩包WEBWORK的源文件压缩包WEBWORK的源文件压缩包WEBWORK的源文件压缩包WEBWORK的源文件压缩包WEBWORK的源文件压缩包WEBWORK的源文件压缩包
webwork源码下载
webwork底层源码,用于webwork框架设计
webwork中文帮助文档 webwork中文帮助文档 webwork中文帮助文档 webwork中文帮助文档 webwork中文帮助文档 webwork中文帮助文档
这是webwork1的jar包,还有webwork-2.2.7.jar和webwork-src-2.2.7.jar