index.jsp里: <%@ taglib prefix="s" uri="/struts-tags" %>
   <s:if test="@org.news.ShowNews@TestIf(3,4) == 7">
    ok
    </s:if>
org.news.ShowNews里:
package org.news;public class ShowNews {

public int TestIf(int i,int j){
return i+j;
}
}出错:
2010-5-17 17:05:43 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find method [@org.news.ShowNews@TestIf(3,4) == 7]
怎么解决?

解决方案 »

  1.   

    1.设置常量
    在struts.xml<constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>2.TestIf方法定义错误    public static int TestIf(int i,int j){
            return i+j;
        }
      

  2.   

    同意油炸冰棍的看法,加static
      

  3.   

    为什么要加static?菜鸟,见笑了...
      

  4.   

    顶1楼 ognl 支持类变量和静态方法的访问 访问方式@【完整包名】@【属性名 or 方法名】
      

  5.   

    LZ的用法是OGNL表达式静态方法调用。struts2默认支持OGNL表达式。