下载jstl-1.2.jar
网址:https://mvnrepository.com/artifact/javax.servlet/jstl/1.2
下载standard-1.1.2.jar
网址:https://mvnrepository.com/artifact/taglibs/standard/1.1.2
配置JSTL标签库
(1)将解压后的jakarta-taglibs-standard-1.1.2\lib目录下的两个jar文件:jstl.jar 和 standard.jar 文件拷贝到您的Web项目的 /WEB-INF/lib/ 目录中。
(2)jakarta-taglibs-standard-1.1.2\tld目录下的tld文件拷贝到您的Web项目的 /WEB-INF/ 目录中。
(3)在 web.xml 文件中,添加以下配置信息:
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/xml</taglib-uri>
<taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/functions</taglib-uri>
<taglib-location>/WEB-INF/fn.tld</taglib-location>
</taglib>
</jsp-config>
验证JSTL的配置是否成功
创建 index.jsp 页面,引用核心标签库:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>,然后使用<c:out>标签输出字符串。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JSTL标签库</title>
</head>
<body>
<c:out value="您好,欢迎访问我的博客!" /><br/>
<c:out value="博客地址" />
</body>
</html>