这要从一个异常说起
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
产生异常的代码是<c:set var="customerid" value="${1+2}"/>
如果使用jstl1.0会产生异常,因为1.0不支持attribute的EL赋值,使用1.1就正常
我们需要在两个地方注意1.0和1.1的使用
一个是web.xml的头


JSTL1.1和JSP2.0

<web-app version="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">


</web-app>


JSTL1.0和JSP1.2


<web-app version="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">


</web-app>
1.0引入方式
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
1.1引入方式
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>