总结:
JSTL1.1的库 在JSP2.0(Servlet 2.4)及以后(推荐用JSTL1.1及以上)用:
- <% @taglib prefix= "c" uri= "http://java.sun.com/[color=red]jsp[/color]/jstl/core" %>
<%@taglib prefix="c" uri="http://java.sun.com/[color=red]jsp[/color]/jstl/core" %>
web.xml
- <?xml version= "1.0" encoding= "UTF-8" ?>
- <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" >
<?xml version="1.0" encoding="UTF-8"?>
<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" >
在 Servlet2.3及以前,
- <% @taglib prefix= "c" uri= "http://java.sun.com/jstl/core" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
比2.4以后版本少了jsp
web.xml
- <?xml version= "1.0" encoding= "UTF-8" ?>
- <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
- <web-app>
- </web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
</web-app>
在Servlet2.3中最好用JSTL1.0 ,如果用JSTL1.1,请加上
- <?xml version= "1.0" encoding= "UTF-8" ?>
- <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
- <web-app>
- <taglib>
- <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
- <taglib-location>/WEB-INF/c.tld</taglib-location>
- </taglib>
- </web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
</web-app>
把tld目录下的c.tld拷贝到/WEB-INF?下。
找到官方下载地址:
http://jakarta.apache.org/site/downloads/downloads_taglibs.html
选择 Standard 1.0 Taglib 和Standard 1.1 Taglib 可以下载jstl1.0和jstl1.1版本。