转载自:http://blog.csdn.net/sd4000784/article/details/7575961

有时候需要在前台显示一些数据、有些数据是需要一些转换的、


这时候就需要使用自己的方法让struts标签经过自己的方法后的数据给显示出来、

比如:有个自己的方法trans(下面只是举个例子)

[java]  view plain copy
  1. public static String trans(String value){    
  2.     
  3.          return value;    
  4.     
  5. }    

然后需要在struts.xml里设置

[html]  view plain copy
  1. <constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>    

而前台的页面使用jsp:

[html]  view plain copy
  1. <s:property value="@com.util.StringUtil@trans('haha')"/>  

haha被单引号引了就代表是字符串、

不写单引号 struts标签就会从域中获取haha属性的值放到trans方法里