struts2的值栈结构
来源:互联网 发布:淘宝店怎么刷销量 编辑:程序博客网 时间:2024/05/21 22:18
public String getValue()
{
this.username = "tomcat";
this.password = "123456";
this.nickname = "tomcat nick";
ActionContext.getContext().put("user", "this is a user");
ServletActionContext.getRequest().setAttribute("pd", "this is a password");
return "value";
}
以上是三种传值方式
下面是EL表达式与OGNL表达式的显示值的试。
el:{usrename}<br/>
el:{password}<br/>
el:{nickname}<br/>
el:{user}<br/>
el:{pd}<br/>
struts:<s:property value="username"/><br/>
struts:<s:property value="password"/><br/>
struts:<s:property value="nickname"/><br/>
struts:<s:property value="user"/><br/>
struts:<s:property value="#request.pd"/><br/>
Struts2的值栈结构,有两种情况,一种是Map结构,一种是List结构,
也就是说ValueStack分为Map和List,而这个Map也就是ActionContext,而List就是CompRoot,是两种不同的数据结构存储方式。
获取Map当中的数据,与List中的数据有的时候都需要加这个“#”号,如果是娶List的第一个元素,第一个元素直接暴露出来,可以直接获取栈顶元素的属性。
Map结构
// Ognl.getValue(expression, context, root);
// System.out.println(Ognl.getValue("sname", context, students));
// System.out.println(Ognl.getValue("rname",context, role));
// System.out.println(Ognl.getValue("#roles.rname",context, students));
// System.out.println(Ognl.getValue("roles.rname",context, context));
System.out.println(Ognl.getValue("#root.sname",context, students));
List结构
System.out.println(Ognl.getValue("get(0).rname",lists));
System.out.println(Ognl.getValue("#root[2].sname",lists));
- struts2的值栈结构
- Struts2的结构
- struts2 struts.xml的结构
- struts2.xml文件的结构
- 简单Struts2的目录结构
- Struts2 结构
- 刚学的Struts2的一些结构
- struts2的值栈
- Struts2的值栈
- struts2的值栈
- struts2的值栈
- 【Struts2源码分析】Struts2框架的大致结构
- Struts2的目录结构(ssh)
- Struts2的工作原理及文件结构
- Struts2值栈的理解
- Struts2值栈的理解
- Struts2值栈的理解
- Struts2的值栈详解
- Linux 移植向导
- java的Future用法
- 向索引添加文档
- 个人开发者做一款Android App需要知道的事情
- qt链接
- struts2的值栈结构
- 程序员篇:8个开发技巧助你薪水更上一层楼
- 程序的灵活性与可扩展性
- 用位运算求两个数的最大值和最小值
- Arcgis for javascript不同的状态下自定义鼠标样式
- priority_queue-Card Game Cheater POJ, 2062
- 院史学得好啊,哈哈哈哈哈哈哈
- 一键清空格工具 V1.0的工具
- Qt5.3.2移植过程,以及一些问题的解决方案的分析。