这要从一个异常说起
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
产生异常的代码是
如果使用jstl1.0会产生异常,因为1.0不支持attribute的EL赋值,使用1.1就正常
我们需要在两个地方注意1.0和1.1的使用
一个是web.xml的头
JSTL1.1和JSP2 .0
= " 2.4 "
xmlns = " http://java.sun.com/xml/ns/j2ee "
xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation = " http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd " >
JSTL1.0和JSP1 .2
= " 2.3 "
xmlns = " http://java.sun.com/xml/ns/j2ee "
xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation = " http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_3.xsd " >
1.0引入方式
<%@ taglib uri="<a href="http://java.sun.com/jstl/core">http://java.sun.com/jstl/core</a>" prefix="c" %>
1.1引入方式
<%@ taglib uri="<a href="http://java.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core</a>" prefix="c"%>