According to TLD or attribute directive in tag file, attribute test does not accept any expressions

According to TLD or attribute directive in tag file, attribute test does not accept any expressions

According to TLD or attribute directive in tag file, attribute test does not accept any expressions在使用struts2 的标签<s:if test="#name == '1'" 的时候一直报这个错误,查找了很久,才知道struts2中已经不支持EL表达式的使用了,只有JSTL还是支持EL表达式的。

在struts2 中只能使用ONGL了,否则就会报上述兼容性的错误了,大家要注意了。JSP EL表达式只能在struts2  标签外部使用或者和JSTL标签一起使用了。



s:if test="${item.flag} ==0  ">

报错According to TLD or attribute directive in tag file, attribute test does not accept any expressions

原因可能是因为你使用了<%..%>代码 or JSP EL表达式。Struts 2从 version 2.0.11开始已经不支持struts tag与JSP EL表达式混合使用了(不在struts tag里使用EL还是可以的),而只支持OGNL (关于OGNL介绍的中文连接:http://www.blogjava.net/max/archive/2007/04/28/114417.html)。

解决方法:

<s:if test="#request.item.flag ==0 ">

参考:http://blog.csdn.net/totogogo/archive/2008/03/07/2157448.aspx

http://blog.csdn.net/bobojava/archive/2009/08/26/4487343.aspx

1.${}是EL语言的 %{}这样的形式是ognl表过式语言的,在struts2的标签内部,使用%{}这样的形式,在标签外部可以使用${}EL语言的方式。如果在struts2的标签内部使用${}这样的方式,会出现以下的错误提示:

According to TLD or attribute directive in tag file, attribute value does not accept any expressions

2. 很多时候,我们使用struts2的一些标签,属性是需要接受集合的,如果集合是保存在 request,session,或者是值栈(非根对象的栈顶),可以使用#变量名的方式,如果获取的值是在Action中通过特定的方法来获取,就需要使用如 value="userList"这样的方式,只是去掉了前面的#。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值