struts2系列十六之复杂的ognl(即<s:pro…..>)变量,类,静态变量,list,map,set
来源:互联网 发布:太阳系3d软件 编辑:程序博客网 时间:2024/06/03 02:09
<constantname="struts.enable.DynamicMethodInvocation"value="false"/>
<constantname="struts.devMode"value="true"/>
<constantname="struts.ognl.allowStaticMethodAccess"value="true"></constant>
<includefile="/com/bjsxt/struts2/ognl/ognl.xml"/>
Jsp页面:
<?xmlversion="1.0"encoding="GB18030"?>
<%@ page language="java"contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ taglib uri="/struts-tags"prefix="s"%>
<!DOCTYPEhtml PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=GB18030"/>
<title>OGNL表达式语言学习</title>
</head>
<body>
<ol>
<li>访问值栈中的action的普通属性:username = <s:propertyvalue="username"/></li>
<li>访问值栈中对象的普通属性(get set方法):<s:propertyvalue="user.age"/> |<s:property value="user['age']"/> |<s:property value="user[\"age\"]"/> | wrong:<%--<s:propertyvalue="user[age]"/>--%></li>
<li>访问值栈中对象的普通属性(get set方法):<s:property value="cat.friend.name"/></li>
<li>访问值栈中对象的普通方法:<s:propertyvalue="password.length()"/></li>
<li>访问值栈中对象的普通方法:<s:propertyvalue="cat.miaomiao()"/></li>
[这个奇特]<li>访问值栈中action的普通方法:<s:propertyvalue="m()"/></li>
<hr/>
<[这个奇特]li>访问静态方法:<s:propertyvalue="@com.bjsxt.struts2.ognl.S@s()"/></li>
[这个奇特]<li>访问静态属性:<s:propertyvalue="@com.bjsxt.struts2.ognl.S@STR"/></li>
[这个不懂]<li>访问Math类的静态方法:<s:propertyvalue="@@max(2,3)"/></li>
<hr/>
[这个奇特]<li>访问普通类的构造方法:<s:propertyvalue="newcom.bjsxt.struts2.ognl.User(8)"/></li>
<hr/>
<li>访问List:<s:propertyvalue="users"/></li>
<li>访问List中某个元素:<s:propertyvalue="users[1]"/></li>
<li>访问List中元素某个属性的集合:<s:propertyvalue="users.{age}"/></li>
<li>访问List中元素某个属性的集合中的特定值:<s:propertyvalue="users.{age}[0]"/> |<s:property value="users[0].age"/></li>
<li>访问Set:<s:propertyvalue="dogs"/></li>
<li>访问Set中某个元素:<s:propertyvalue="dogs[1]"/></li>
<li>访问Map:<s:propertyvalue="dogMap"/></li>
<li>访问Map中某个元素:<s:propertyvalue="dogMap.dog101"/> |<s:property value="dogMap['dog101']"/> |<s:property value="dogMap[\"dog101\"]"/></li>
<li>访问Map中所有的key:<s:propertyvalue="dogMap.keys"/></li>
<li>访问Map中所有的value:<s:propertyvalue="dogMap.values"/></li>
<li>访问容器的大小:<s:propertyvalue="dogMap.size()"/> |<s:property value="users.size"/></li>
<hr/>
[这个不懂]<li>投影(过滤):<s:propertyvalue="users.{?#this.age==1}[0]"/></li>
[这个不懂]<li>投影:<s:propertyvalue="users.{^#this.age>1}.{age}"/></li>
[这个不懂]<li>投影:<s:propertyvalue="users.{$#this.age>1}.{age}"/></li>
[这个不懂]<li>投影:<s:propertyvalue="users.{$#this.age>1}.{age} == null"/></li>
<hr/>
[这个不懂]<li>[]:<s:propertyvalue="[0].username"/></li>
</ol>
<s:debug></s:debug>
</body>
</html>
具体理解:
1集合List,set map正常
2对象正常,普通方法正常,静态方法正常,新建对象正常
3 user对象在 jsp页面使用了get方法,set个人理解是在 传递参数的时候才起作用
4 剩下的投影不太理解,不知是否常用。
- struts2系列十六之复杂的ognl(即<s:pro…..>)变量,类,静态变量,list,map,set
- struts2 ognl 中引用java静态变量
- J2EE系列之Struts2学习笔记(十五)--OGNL访问复杂对象、静态属性和静态方法
- struts2中OGNL中访问静态变量和静态方法
- Struts2 中 OGNL 如何更简单的访问静态变量和静态方法
- swift - 类型方法(即静态变量)
- Struts2变量--ognl中的#、%和$
- Struts2的OGNL遍历数组、List、简单的Map
- Struts2的OGNL遍历数组、List、简单的Map
- Struts2+OGNL传递参数List,Map的一个小例子
- Struts2 在页面定义变量 s:set标签
- Struts2 在页面定义变量 s:set标签
- java线程安全问题之静态变量、实例变量(类变量)、局部变量
- struts2系列六之使用实体类变量作为参数
- 在创建实例变量的时候用Set,List,Map等接口声明类型而不是用具体的子类声明的原因之代码重构
- List 序列化与反序列化到struts2的<s:hidden>变量
- java静态变量(类变量)和普通变量(实例变量)的区别
- 成员变量、类变量(静态变量)、局部变量的区别
- struts2系列十四之globalresult全局返回结果
- 如何使用C#加密解密XML文档
- 1352 - Colored Cubes (枚举方法)
- 串行通信实验
- struts2系列十五之result path返回路径为动态结果
- struts2系列十六之复杂的ognl(即<s:pro…..>)变量,类,静态变量,list,map,set
- 服务器种类有哪些?
- json
- 智能温度监测系统
- Cookie例子
- struts2系列十七之常用的struts标签set,property,iterator,include,if,error,判断奇偶
- VS2010进行远程调试方法总结
- dorado单独给结果集中的字段赋值
- 计算器的设计和实现