0x01 环境搭配
如果还不会搭建jsp环境的可以按照下面的文章跟着搭建
Mac版IDEA创建maven web项目-详细过程: https://www.yuque.com/pmiaowu/gpy1q8/npv0fr
0x02 安装JSTL库
0x02.1 maven安装JSTL库
0x02.1.1 安装JSTL
打开: https://mvnrepository.com/
搜索: JSTL
点进去: https://mvnrepository.com/artifact/javax.servlet/jstl
我这里选择1.2
打开: https://mvnrepository.com/artifact/javax.servlet/jstl/1.2
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
0x02.1.2 安装taglibs
打开: https://mvnrepository.com/
搜索: taglibs
点进去: https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl
我这里选择1.2.5
打开: https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl/1.2.5
<!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl -->
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<version>1.2.5</version>
<scope>runtime</scope>
</dependency>
0x02.2 手动安装JSTL库
0x02.2.1 JSTL包下载
首先介绍如何手动下载jar包
打开: https://mvnrepository.com/artifact/javax.servlet/jstl/1.2
下载: https://repo1.maven.org/maven2/javax/servlet/jstl/1.2/jstl-1.2.jar
0x02.2.2 taglibs包下载
打开: https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl/1.2.5
打开: https://repo1.maven.org/maven2/org/apache/taglibs/taglibs-standard-impl/1.2.5/
下载: https://repo1.maven.org/maven2/org/apache/taglibs/taglibs-standard-impl/1.2.5/taglibs-standard-impl-1.2.5.jar
0x02.2.3 导入JSTL包与taglibs包
把jstl-1.2-sources.jar
与taglibs-standard-impl-1.2.5.jar
下载到本地以后
把这两个文件拷贝到 /WEB-INF/lib/
下就可以了
如果WEB-INF
下面没有lib
文件夹,那就自己创建个lib
文件夹
0x03 测试小例子
// 目录结构
├── src
│ └── main
│ └── webapp
│ └── com
│ │ └── ...
│ └── WEB-INF
│ │ └── web.xml
│ ├── ...
│ └── JSTL库测试
│ │ ├── test1.jsp
// 文件地址: ./src/main/webapp/JSTL库测试/
// 文件名称: test1.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--引入对应标签--%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>JSTL库测试-1</title>
</head>
<body>
<c:out value="<要显示的数据对象(未使用转义字符)>" escapeXml="true" default="默认值"></c:out>
</body>
</html>
// 打开: http://127.0.0.1:8081/mavenJspTest_war/JSTL库测试/test1.jsp