【发布时间】:2013-03-04 07:26:15
【问题描述】:
我正在尝试使用 JSTL,但出现以下错误:
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
这是如何引起的,我该如何解决?
【问题讨论】:
我正在尝试使用 JSTL,但出现以下错误:
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
这是如何引起的,我该如何解决?
【问题讨论】:
在您的 JSP 中使用 taglib 定义,或者最好将其包含在每个页面的第一行。
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
您的项目中还修复了jstl-1.2 依赖项。还要在web.xml 中使用至少 2.4 的 servlet 规范。
maven依赖是(maven是开源开发工具)
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<scope>compile</scope>
</dependency>
在web.xml开始写
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
编辑:
我想添加一条注释,@informatik01 在评论中提到了有关 Maven 存储库中可用的新版本 JSTL 库的注释:JSTL version 1.2.1 API 和 JSTL 1.2.1。
【讨论】:
即使在为 jstl 和标准添加 jar 文件后,我也遇到了同样的问题。对我来说,在我为我的项目添加了 Targeted 运行时后它就解决了。
转到 Project Properties > Targeted Runtimes 并选择您正在使用的服务器(对我来说是 Tomcat 7.0)。
【讨论】:
在里面的WEB-INF目录下创建一个libs文件夹,添加jstl,标准jar如下。
【讨论】:
你可以尝试把包含jsp-s的文件夹变成eclipse的源文件夹,解决了我同样的问题。如下:
- 打开项目的属性。(右键单击项目,然后选择属性)
- 选择Java Build Path,选择Source选项卡,点击Add Folder并选择包含你的jsp-s的文件夹,OK
【讨论】:
在你的 pom.xml 中添加
<!-- jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
然后尝试运行
mvn eclipse:eclipse -Dwtpversion=2.0
解决问题
【讨论】:
您只需在项目构建路径中包含standard.jar 文件即可。
【讨论】:
我也有类似的问题,为什么我们在使用maven的时候要添加外部jar文件?
我已经包含了 jstl maven 依赖项,然后我也遇到错误“找不到“http://java.sun.com/jsp/jstl/core”的标记库描述符”。 然后我包含以下依赖项然后错误得到解决,不包含任何单个外部 jar 文件。
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
【讨论】: