struts2中<s:property>的用法
1,访问Action值栈中的普通属性:
<s:property value="attrName"/>
2,访问Action值栈中的对象属性(要有get set方法):
<s:property value="obj.attrName"/>
<s:property value="obj1.obj2.attrName"/>
3,访问值栈中对象属性的方法
<s:property value="obj.methodName()"/>
4,访问值栈中action的普通方法:
<s:property value="methodName()"/>
5,访问静态方法:
<s:property value="@com.softeem.LoginAction@methodName()"/>
6,访问静态属性:
配置属性文件,允许ognl访问静态方法struts.ognl.allow...=true
<s:property value="@com.softeem.LoginAction@attrName"/>
7,访问Math类的静态方法:
<s:property value="@@min(9,7)"/>
8,访问普通类的构造方法:
<s:property value="new com.softeem.User(2)"/>
9,访问集合:
①list集合对象
<s:property value="listName"/>
②list集合中的某个元素
<s:property value="listName[1]"/>
③list中某个属性的集合
<s:property value="listName.{field}"/>
④list中某个属性集合的特定值
<s:property value="listName.{field}[0]"/>
⑤访问set
<s:property value="setName"/>
⑥访问set中某个元素
<s:property value="setName[0]"/>
⑦访问map
<s:property value="mapName"/>
⑧根据key访问Map中的元素
<s:property value="mapName.username"/>
<s:property value="mapName['username']"/>
<s:property value="mapName[/"username/"]"/>
⑨访问map中所有的key
<s:property value="mapName.keys"/>
10,访问map中所有的values
<s:property value="mapName.values"/>
11,访问map的大小
<s:property value="mapName.size()"/>
12,投影
<s:property value="listName.{?#this.age==1}"/>
<s:property value="listName.{^#this.age>1}"/>
<s:property value="listName.{$#this.age==1}"/>
<s:property value="listName.{$#this.age==1}.{age}==null"/>
[]:<s:property value="[0]"/>值栈中的对象
---------------------------------------
访问action中传过来的对象:<s:property value="user"/>|${user }<br>
访问action中传过来的对象中的属性:<s:property value="user.username"/>|${user.username }<br>
访问action中传过来的对象属性类中的方法:<s:property value="user.getUsername()"/><br>
访问action中传过来的对象中的对象:<s:property value="user.group"/><br>
访问action中传过来的对象中的对象的属性:<s:property value="user.group.gname"/> |
<s:property value="user.group.getGname()"/><br>
访问action中的普通方法:<s:property value="getValue()"/><br>
访问其他类中过的静态方法:<s:property value="@com.softeem.pojos.User@printUser()"/><br>
取到Math类中的方法:<s:property value="@@max(12,45)"/><br>
访问User类的构造方法:<s:property value="new com.softeem.pojos.User()"/><br>
访问list:<s:property value="users"/><br>
获取list的长度:<s:property value="users.size()"/><br>
取到list中第一个元素:<s:property value="users.get(0)"/>|<s:property value="users[1]"/><br>
取到list中username属性的集合:<s:property value="users.{username}"/><br>
根据key取到map中的元素:<s:property value="userMap.张三"/>|
<s:property value="userMap['三毛']"/><br>
⑨访问map中所有的key:<s:property value="userMap.keys"/><br>
10,访问map中所有的values:<s:property value="userMap.values"/><br>
11,访问map的大小:<s:property value="userMap.size()"/><br>
12,投影:<s:property value="users.{?#this.username=='张三'}.{password}"/><br>
13,取到list中满足条件的开头的一个元素的密码:<s:property value="users.{?#this.username='张三'}.{password}[0]"/><br>
14,取到list中满足条件的最后的一个元素的密码:<s:property value="users.{$#this.username='张三'}.{password}"/><br>
15,<s:property value="users.{$#this.username=='admin'}.{group}==null"/><br>
16,从栈顶开始取,一直取到指定的位置(0表示栈底):<s:property value="[1]"/>
<s:debug></s:debug>
struts2中<s:property>的用法的更多相关文章
- Struts2中OGNL表达式的用法
今天分享的是Struts2框架中的一种ognl表达式语言,主要分两个目标去学习 1.理解struts2传值的优先级 2.ognl与el的区别 一:ognl表达式语言简介 OGNL的全称是O ...
- struts2中<s:checkboxlist/>的用法详解
Html代码 选择角色<br> <s:checkboxlist list="#request.roleuserList" listKey="roleId ...
- struts2中s:iterator 标签的使用详解 及 OGNL用法
简单的demo: s:iterator 标签有3个属性:value:被迭代的集合id :指定集合里面的元素的idstatus 迭代元素的索引 1:jsp页面定义元素写法 数组或list <s ...
- Objective-C中的@property和@synthesize用法
@代表“Objective-C”的标志,证明您正在使用Objective-C语言 Objective-C语言关键词,@property与@synthesize配对使用. 功能:让编译好器自动编写一个与 ...
- Struts2中的get、set方法作用:
Struts2中的get.set方法作用: 在Struts2中,客户端和服务器之间的数据传输全部要用到get.set方法:用set方法 ,可以将表单中的值存入Action类.通过Struts2.0标签 ...
- [转]STRUTS2中的OGNL
OGNL表达式是(Object-Graph Navigation Language)是对象图形化导航语言.OGNL是一个开源的项目,struts2中默认使用OGNL表达式语言来显示数据.与serlve ...
- struts2中的s标签
那就从简单的标签说起吧!1.x中常用的标签只有4中html.bean.logic.tiles 而struts2.0里的标签却没有分类,只用在jsp头文件加上 <%@ taglib prefix= ...
- OC中的@property详解
简介: @property 生成了变量的get set 方法,同时指定了变量名称. 例如@property (nonatomic,strong) NSString *name;表示生成了_name私有 ...
- jsp\struts1.2\struts2 中文件上传(转)
jsp\struts1.2\struts2 中文件上传 a.在jsp中简单利用Commons-fileupload组件实现 b.在struts1.2中实现c.在sturts2中实现现在把Code与大家 ...
随机推荐
- Countly在andoid和vps集成使用,开源的统计分析sdk
这几天项目需要,简单研究了一下countly,说实话完全满足项目需要,比umeng这类产品干净多了. Countly Mobile Analytics 下面就讲一下android 集成的过程,以及 服 ...
- zoj 1622 Switch 开关灯 简单枚举
ZOJ Problem Set - 1622 Switch Time Limit: 2 Seconds Memory Limit: 65536 KB There are N lights i ...
- Python Django manage.py提供的命令及用法
λpython manage.pyType'manage.py help <subcommand>'for help on a specific subcommand. Available ...
- flex开发小技巧集锦
关于flex开发网上有非常多的相关信息介绍,因此我们要想学习关于flex开发的知识信息技能是一件非常简单和方便的事情.而针对于flex开发小编要告诉大家的是一些flex开发小技巧.利用这些小技巧能够有 ...
- ECSHOP在线手册布局参考图--登录/注册页 user_passport.dwt
A.会员登录框 1,设置方法 自带模块 2,代码相关 user_passport.dwt 中 <div class="usBox_1 f_l"> <div ...
- HTML5要点(二)
<p> <b>今天周一</b>,<span>呵呵呵呵呵...</span> </p> <i>斜体文字</i&g ...
- NSThead
每个iOS应用程序都有个专门用来更新显示UI界面.处理用户的触摸事件的主线程,因此不能将其他太耗时的操作放在主线程中执行,不然会造成主线程堵塞(出现卡机现象),带来极坏的用户体验.一般的解决方案就是将 ...
- 使用教程sqlite
访问地址: http://www.runoob.com/sqlite/sqlite-where-clause.html
- android常见错误-The container 'Android Dependencies' references non existing library
The container 'Android Dependencies' references non existing library
- ConvertHelper与泛型集合
在机房重构时.我们常常会用到ConvertHelper. 它把从数据库中查询到的dateTable(也是一个暂时表)转化为泛型,然后再填充到DataGridView控件中. ConvertHelper ...