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

来源:互联网 发布:詹姆斯06年数据 编辑:程序博客网 时间:2024/05/24 00:16

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
原创粉丝点击