struts2中OGNL中访问静态方法
2009-12-21 14:16
246 查看
在struts2中,有时需要使用ognl去访问静态方法,典型的例子是,在新闻发布系统中,如果标题大于某个字数,必须截断,
于是可以这样做:
首先写一个静态的方法,然后在页面中这样写:
<s:property value="@com.abc.common.StringHelper@splitString(title,36,'...')"/>
其中@com.abc.common是包的名,StringHelper是类的名,splitString是静态方法的名,
要注意的是,必须在struts.xml中设置
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
于是可以这样做:
首先写一个静态的方法,然后在页面中这样写:
<s:property value="@com.abc.common.StringHelper@splitString(title,36,'...')"/>
其中@com.abc.common是包的名,StringHelper是类的名,splitString是静态方法的名,
要注意的是,必须在struts.xml中设置
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
相关文章推荐
- struts2中OGNL中访问静态方法
- struts2中OGNL中访问静态方法
- struts2中OGNL中访问静态方法
- 道听途说Struts2之19:OGNL访问静态方法,集合类
- Struts2中使用OGNL表达式语言访问静态方法和静态属性以及我遇到的问题和解决方法
- struts2 ognl访问静态方法一定要配置!!!否则不能访问
- Struts2 中 OGNL 如何更简单的访问静态变量和静态方法
- struts2中OGNL中访问静态方法
- struts2中OGNL中访问静态变量和静态方法
- struts2中OGNL中访问静态方法
- struts2-ognl 访问静态方法
- Struts2 OGNL调用公共静态方法
- struts2 ognl静态方法调用无效
- Struts2学习——1400OGNL2访问方法与属性
- Struts2 标签 访问静态方法 无响应 的解决办法
- struts2 ognl 访问静态属性
- ognl表达式访问普通属性和静态方法
- Struts2的OGNL调用公共静态方法
- Struts2中使用OGNL调用静态方法及静态属性
- Struts2中使用struts2标签访问静态方法