index.jsp
tomcat的lib下面自带servlet-api,jsp-api拷贝到web-inf 目录下的lib
如果导入了jstl就会报错,注释掉就不会报错
<%--
Created by IntelliJ IDEA.
User: 34671
Date: 2023/4/19
Time: 10:33
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>--%>
<html>
<head>
<title>$Title$</title>
</head>
<body>
11111111111
<%-- 保存之前:${ sessionScope.abc } <br>--%>
<%-- <c:set scope="session" var="abc" value="abcValue"/>--%>
<%-- 保存之后:${ sessionScope.abc } <br>--%>
</body>
</html>
如何解决jstl导入报错的问题
HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
type Exception report message The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml
1.首先,确保项目中包含了JSTL和标准实现包,注意版本匹配!
2.此处使用JSTL1.2.x版本演示,导入的依赖如下,如果非maven项目则导入jstl和标准实现包放到lib目录中
<!-- JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- JSTL实现包 -->
<dependency>
<groupId>org.apache.taglibs</groupId>
<artifactId>taglibs-standard-impl</artifactId>
<version>1.2.5</version>
</dependency>
3.标准实现包下载完成或者依赖下载完成之后,找到该jar包,然后使用压缩工具解压
4.进入压缩包中的taglibs-standard-impl-1.2.5\META-INF\中我们可以看到有如下描述文件
5.选择自己需要的描述文件放到项目的WEB-INF下,选择的时候不要选择带有1和0这样的,基本上我们选择c.tld也就是c标签通常就够用了
6.在web.xml中加入jsp-config配置,其中taglib-uri是自己需要在jsp文件中指定uri时使用,taglib-location是上一步拷贝的描述文件位置,如果是放在WEB-INF下的话就是"/WEB-INF/xxx.tld",注意需要多少个描述文件就有多少个<taglib>...</taglib>,但是只有一个<jsp-config>
<!-- 自己配置描述文件,需要多少个描述文件就配置多少 -->
<jsp-config>
<!-- 配置c描述文件-对应c标签,这里的taglib-uri对应jsp中引入的uri -->
<taglib>
<taglib-uri>http://www.codecoord.com</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://www.codecoord.com/fn</taglib-uri>
<taglib-location>/WEB-INF/fn.tld</taglib-location>
</taglib
</jsp-config>
7.完成后在JSP文件中引用,uri记住是自己在web.xml中创建的
原文链接:https://blog.csdn.net/sinat_34104446/article/details/82846585