s:if标签 :警告: Could not find method [@org.news.ShowNews@TestIf(3,4) == 7]

sb3day 2010-05-17 05:11:14
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]
怎么解决?
...全文
231 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
redlotus_lyn 2010-05-18
  • 打赏
  • 举报
回复
LZ的用法是OGNL表达式静态方法调用。

struts2默认支持OGNL表达式。
japt88_115656292 2010-05-18
  • 打赏
  • 举报
回复
应该是的。。。。jf
ditouye 2010-05-17
  • 打赏
  • 举报
回复
up......
q317621051 2010-05-17
  • 打赏
  • 举报
回复
【完整包名。类名】。。。。。。。。。。。。。。。
q317621051 2010-05-17
  • 打赏
  • 举报
回复
顶1楼 ognl 支持类变量和静态方法的访问 访问方式@【完整包名】@【属性名 or 方法名】
lzt2008 2010-05-17
  • 打赏
  • 举报
回复
不是静态的方法
怎么用类去引用啊
sb3day 2010-05-17
  • 打赏
  • 举报
回复
为什么要加static?

菜鸟,见笑了...
Fairy_dy 2010-05-17
  • 打赏
  • 举报
回复
同意油炸冰棍的看法,加static
ladybirds2008 2010-05-17
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 redlotus_lyn 的回复:]

1.设置常量
在struts.xml

<constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>

2.TestIf方法定义错误
public static int TestIf(int i,int j){
return i+j;
}
[/Quote]
redlotus_lyn 2010-05-17
  • 打赏
  • 举报
回复
1.设置常量
在struts.xml

<constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>

2.TestIf方法定义错误

public static int TestIf(int i,int j){
return i+j;
}
sb3day 2010-05-17
  • 打赏
  • 举报
回复
up

.

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧