struts2 - View页面中获取Action的成员变量
来源:互联网 发布:jpeg标准量化算法 编辑:程序博客网 时间:2024/04/28 12:48
View页面中获取Action的成员变量
按照Struts的设计,在Action处理完后,把结果数据保存在自己的成员变量里,然后跳至result指定的页面(VIEW页面)。
VIEW页面负责展现处理结果,那VIEW中如何获取Action的数据呢?
方法一:Struts2 Property Tag / OGNL
http://struts.apache.org/2.x/docs/using-struts-2-tags.html
http://www.vaannila.com/struts-2/struts-2-example/struts-2-ognl-expression-language-example-1.html
比如,在Action里有一个成员变量helloCount及其对应的getter
private int helloCount = 0;
public int getHelloCount() {
return helloCount;
}
public void setHelloCount(int helloCount) {
HelloWorldAction.helloCount = helloCount;
}
则在VIEW.jsp中,
宣布使用struts的tag
<%@ taglib prefix="s" uri="/struts-tags" %>
可以使用下面的tag来显示helloCount的值:
I've said hello <s:property value="helloCount" />
方法二: HttpRequest的getAttribute方法
实际上, 在Action处理完之后,跳到result页面之前,struts应用把Action对象的成员变量放到了request的属性里(机制未知)
所以,可以用request对象来获取Action的成员变量。
【似乎只能获取Object,不能获取int这种变量】
<%
String username = (String) request.getAttribute("username");
%>
- struts2 - View页面中获取Action的成员变量
- struts2 - View页面中获取Action的成员变量
- struts2 action中成员变量的生存周期
- struts2 action中获取jsp页面的参数的方法
- struts2 action中获取jsp页面的参数的方法
- struts2中 action获取jsp页面的参数的方法
- Struts2的学习(2)--Action类成员变量怎么获取表单属性值
- struts2中action获取jsp页面参数
- Struts2中Action获取Jsp页面信息
- jsp页面通过 request对象直接获取 struts2 Action的变量的值。
- STRUTS2--JSP页面向Action中Set类型成员中传值
- 在jsp的<s:iterator>标签中获取action中的定义的成员变量
- Struts2中Action获取JSP页面传参的方法,及Action获取request的每个方法的区别
- 在struts2的action中获取或设置http型session变量的值
- 在struts2的action中获取或设置http型session变量的值
- struts2中action如何获取jsp页面参数
- struts2中action如何获取jsp页面参数
- Struts2框架中action无法获取到jsp页面传递的表单数据的解决办法
- 垃圾包围福利院六年 官方称暂找不到地方
- 【编程好习惯】减少搜索头文件的目录数
- XNA Billboard(公告板技术)
- jQuery,使用on代替delegate,live 写法区别
- Action中读写Session
- struts2 - View页面中获取Action的成员变量
- Wakelocks for Android*
- Android的Message机制(简单小结)
- 使用PHP单例模式
- oracle 触发器的实例
- msvcr90.dll!_invalid_parameter_noinfo() Line 125 + 0xc bytes 的排错
- iOS开发者们,请尽量不要在夏季开发应用!
- Android之Activity 生命周期介绍【图解】
- PostgreSQL use redis_fdw connect to Redis