pache Tomcat安裝JSTL 庫步驟如下:
從Apache的標准標簽庫中下載的二進包(jakarta-taglibs-standard-current.zip)。
- 官方下載地址:http://archive.apache.org/dist/jakarta/taglibs/standard/binaries/
- 本站下載地址:jakarta-taglibs-standard-1.1.2.zip
下載jakarta-taglibs-standard-1.1.2.zip 包並解壓,將jakarta-taglibs-standard-1.1.2/lib/下的兩個jar文件:standard.jar和jstl.jar文件拷貝到/WEB-INF/lib/下。
接下來我們在 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"> <jsp-config> <taglib> <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri> <taglib-location>/WEB-INF/fmt.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri> <taglib-location>/WEB-INF/fmt-rt.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/core</taglib-uri> <taglib-location>/WEB-INF/c.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri> <taglib-location>/WEB-INF/c-rt.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri> <taglib-location>/WEB-INF/sql.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri> <taglib-location>/WEB-INF/sql-rt.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/x</taglib-uri> <taglib-location>/WEB-INF/x.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri> <taglib-location>/WEB-INF/x-rt.tld</taglib-location> </taglib> </jsp-config> </web-app>
使用任何庫,你必須在每個JSP文件中的頭部包含<taglib>標簽。
核心標簽
核心標簽是最常用的JSTL標簽。引用核心標簽庫的語法如下:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
