【解决】- According to TLD or attribute directive in tag file, attribute test does not accept any expre
今天在写 JavaWeb 作业的时候 ,使用EL 比表达式 一直报错According to TLD or attribute directive in tag file, attribute test does not accept any expressions
具体错误如下
代码
很疑惑 ,仔细检查之后发现我的代码并没有写错 , 并且 jstl 标签库导入的也没问题 . 最只能求助
百度 , 查了之后 发现是因为 jsp版本 我的是 4.0 ? 难道是因为不兼容 ? 下面是百度到的解决方
解决方法
问题原因:
因为使用了 JSP 2.0, 但又没有使用 JSTL 标签库的备用版本(RT库)
应用部署运行的时候出现JSP异常, 发生在使用JSTL库的时候: According to TLD or attribute directive in tag file, attribute value does not accept any expressions, 可能是因为使用了JSP2.0版本, 同时又没有使用JSTL core库的备用版本(RT库), 一种简单的解决方法是使用JSTL core RT库
JSTL core库的有两种taglib伪指令, 其中RT库即是依赖于JSP传统的请求时属性值, 而不是依赖于EL来实现(称为EL库.JSP2.0将支持EL)
JSP中使用<%@ taglib uri=http://java.sun.com/jstl/core prefix=“c”%>在2.3版本都可以,在2.4就不行了
解决方案:
方案1. 修改web.xml
将 web.xml 中的 声明由 2.4 或 2.5 版本的修改为 2.3 版本,如:
修改为:
方案2. 使用JSTL core RT库
JSTL 标签库的有两种 taglib 伪指令, 其中 RT 库即是依赖于 JSP 传统的请求时属性值, 而不是依赖于 EL 来实现:
只要将
<%@ taglib uri=“http://java.sun.com/jstl/core” prefix=“c”%>
改为
<%@ taglib uri=http://java.sun.com/jstl/core_rt prefix=“c”%>