tomcat8使用jstl配置环境
下载tomcat8
用tomcat10会出现不兼容报错500服务器异常
下载链接
https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.90/bin/apache-tomcat-8.5.90-windows-x64.zip
创建maven工程
创建web工程
maven配置导入jar包
在生成的工程文件中有一个pom.xml文件
在文件中的<dependencies>标签中填写以下代码
tomcat9以前使用javax包
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.web/javax.servlet.jsp.jstl -->
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-spec</artifactId>
<version>1.2.5</version>
## 在jsp页面中导入资源
<%@ taglib prefix=“c” uri=“http://java.sun.com/jstl/core” %>
prefix标签可以自定义名称;
编写一个简单的测试代码
<html>
<head>
<title>Title</title>
</head>
<body>
<c:if test="true">
<h1>成功</h1>
</c:if>
</body>
</html>
启动tomcat服务器后访问你测试的jsp页面会在页面上打印<h1>标签属性的成功
maven镜像源:
https://mvnrepository.com/