JSP学习笔记(二十一):struts2中访问request,application对象

一、 request对象

 

struts2 action中访问:

HttpServletRequest request = ServletActionContext.getRequest();

String str 
= request.getParameter("parm");

页面中访问:

<s:property value="#request.parm" />

相当于JSP中的:

request.getParameter("parm")

二、 application对象

 

struts2 action中访问:

ActionContext context = ActionContext.getContext();
Map app = context.getApplication();

String str 
= app.get("parm").toString();

servlet中访问:

this.getServletContext().getAttribute("parm");

页面中访问:

<s:property value="#application.parm" />

相当于JSP中的:

application.getParameter("parm")

这只是一个简单的例子,想知道更多关于OGNL的内容,可以参考此文:http://www.blogjava.net/max/category/16130.html

posted @ 2008-08-20 09:27  魔豆  阅读(2265)  评论(0编辑  收藏  举报