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>的用法的更多相关文章

  1. Struts2中OGNL表达式的用法

    今天分享的是Struts2框架中的一种ognl表达式语言,主要分两个目标去学习    1.理解struts2传值的优先级    2.ognl与el的区别 一:ognl表达式语言简介 OGNL的全称是O ...

  2. struts2中<s:checkboxlist/>的用法详解

    Html代码 选择角色<br> <s:checkboxlist list="#request.roleuserList" listKey="roleId ...

  3. struts2中s:iterator 标签的使用详解 及 OGNL用法

    简单的demo: s:iterator 标签有3个属性:value:被迭代的集合id   :指定集合里面的元素的idstatus 迭代元素的索引 1:jsp页面定义元素写法 数组或list <s ...

  4. Objective-C中的@property和@synthesize用法

    @代表“Objective-C”的标志,证明您正在使用Objective-C语言 Objective-C语言关键词,@property与@synthesize配对使用. 功能:让编译好器自动编写一个与 ...

  5. Struts2中的get、set方法作用:

    Struts2中的get.set方法作用: 在Struts2中,客户端和服务器之间的数据传输全部要用到get.set方法:用set方法 ,可以将表单中的值存入Action类.通过Struts2.0标签 ...

  6. [转]STRUTS2中的OGNL

    OGNL表达式是(Object-Graph Navigation Language)是对象图形化导航语言.OGNL是一个开源的项目,struts2中默认使用OGNL表达式语言来显示数据.与serlve ...

  7. struts2中的s标签

    那就从简单的标签说起吧!1.x中常用的标签只有4中html.bean.logic.tiles 而struts2.0里的标签却没有分类,只用在jsp头文件加上 <%@ taglib prefix= ...

  8. OC中的@property详解

    简介: @property 生成了变量的get set 方法,同时指定了变量名称. 例如@property (nonatomic,strong) NSString *name;表示生成了_name私有 ...

  9. jsp\struts1.2\struts2 中文件上传(转)

    jsp\struts1.2\struts2 中文件上传 a.在jsp中简单利用Commons-fileupload组件实现 b.在struts1.2中实现c.在sturts2中实现现在把Code与大家 ...

随机推荐

  1. UIImagePickerController Class 概述

    不能定制界面,不可派生子类. 使用步骤: 检查制定源是否可用. isSourceTypeAvailable:方法.    检查可用媒体(视频还是只能是图片) availableMediaTypesFo ...

  2. 转载ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction区别

    对这四个的区别做一个总结,清理一下思路,方便以后使用: 1.带有Render的方法返回值是void,在方法内部进行输出:不带的返回值类型为MvcHtmlString,所以只能这样使用:     @Ht ...

  3. Java与MySql数据类型对照表

    类型名称 显示长度 数据库类型 JAVA类型 VARCHAR L+N VARCHAR java.lang.String CHAR N CHAR java.lang.String BLOB L+N BL ...

  4. UITextView光标在中间的问题

    if ([self respondsToSelector:@selector(setAutomaticallyAdjustsScrollViewInsets:)]) { self.automatica ...

  5. UIAlertViewController+TextField 输入框

    if (IOS8) { UIAlertController *alertController=[UIAlertController alertControllerWithTitle:CustomLoc ...

  6. nape.geom.MarchingSquares

    Nape中的MarchingSquares类很简单,只有一个静态函数run,不过这对绘制那些简单的形状来说,已经足够了(当然MarchingSquares能做的不只这些).下面是这个run方法的结构: ...

  7. SPOJ - OTOCI LCT

    OTOCI Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/problem/viewProblem. ...

  8. 设计模式之十三:适配器模式(Adapter)

    适配器模式: 将一个类的接口转换成另外一个期望的类的接口.适配器同意接口互不兼容的类一起工作. Convert the interface of a class into another interf ...

  9. sphinx的简单实例

    sphinx.conf中的配置: source indexLocation { type = mysql sql_host = 192.168.1.113 sql_user = root sql_pa ...

  10. html5中viewport使用

    html5中viewport使用 转载自:http://www.maoegg.com/the-usage-of-viewport-in-html5/ 用html5开发移动应用时往往会遇到手机的分辨率或 ...