今天给学生讲JSTL核心库里的<c:out>标签,做演示时无任何问题,但学生在练习时<c:out value="abc" default="123"/>可以正常显示,在使用<c:out value="${name}">使用EL表达式取request值时报下面的异常:
org.apache.jasper.JasperException: /jsp/pages/MyJsp.jsp(4,0) According to TLD or attribute directive in tag file, attribute end does not accept any expressions...
后经研究发现这是JSTL版本的问题 :
jstl的1.0的版本有两个tld,以core为例,core.tld和core_rt.tld,后者支持表达式,jstl 1.1的core.tld就都支持了
在使用JSTL1.1时发现上面错误. 必须将第一行换成:
<%@ taglib prefix="c" http://java.sun.com/jstl/core_rt" %>
才正确.