一、下载链接
官方文档:https://archive.apache.org/dist/jakarta/taglibs/standard/binaries/
在文档中下载最新一版的ZIP文件(文档包文件版本为:jakarta-taglibs-standard-1.1.2.zip)
二、导入JAR包
-
解压ZIP文件,在lib目录下找到
jstl.jar
standard.jar
-
IDEA项目中在 WEB-INF 目录下新建 lib 目录
-
全选刚刚两个文件选中 lib 目录复制进其路径下
三、添加到工程目录
- 选中 jar 包右键选择添加为库 (无汉化为 Add as Library…)
两个 jar 包均同样操作
添加后的目录
四、添加 tlb 文件
1.在 WEB-INF 目录下新建 tlb 目录
2. 引入 tlb 目录下需要的 tld 文件(同上拷贝到 tlb 目录下)
五、在 WEB.xml 中配置文件信息
配置信息如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt-1_0.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/c-1_0.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/sql-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/sql-1_0.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/x</taglib-uri>
<taglib-location>/WEB-INF/tld/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/x-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/x-1_0.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
六、在需要使用标签库的jsp页面,使用 taglib 指令引入标签库。
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>