spring Sun JSTL taglib 声明失败并显示“找不到标记库描述符”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13595511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sun JSTL taglib declaration fails with "Can not find the tag library descriptor"
提问by Atma
I am using a JSP page to print an array of values. I'm trying to use JSTL <c:forEach>for this.
我正在使用 JSP 页面打印一组值。我正在尝试为此使用 JSTL <c:forEach>。
<c:forEach items="${objects}" var="object">
<td>${object.name} </td>
</c:forEach>
The problem is my JSTL taglib declaration:
问题是我的 JSTL taglib 声明:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
The IDE shows an error on this line
IDE 在这一行显示错误
Can not find the tag library descriptor.
找不到标记库描述符。
Many of the forums point to the old Sun site to download the JSTL libraries. Now all of these links point to the Oracle home page with no link to JSTL binaries. This is leading me to believe there is a newer approach to accomplish this.
许多论坛都指向旧的 Sun 站点以下载 JSTL 库。现在所有这些链接都指向 Oracle 主页,而没有链接到 JSTL 二进制文件。这让我相信有一种更新的方法可以实现这一目标。
回答by Babu Subburathinam
To resolve this issue:
要解决此问题:
The
jstl jarshould be in your classpath. If you are using maven, add a dependency to jstl in yourpom.xmlusing the snippet provided here. If you are not using maven, download the jstl jar from hereand deploy it into yourWEB-INF/lib.Make sure you have the following taglib directive at the top of your
jsp:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
回答by BalusC
Just check our own JSTL wiki pagefor the proper download links and crystal clear installation instructions.
只需查看我们自己的JSTL wiki 页面,即可获得正确的下载链接和清晰的安装说明。
Put your mouse above the [jstl]tag which you put on the question yourself until a black box shows up and click therein the infolink.
将鼠标放在您[jstl]自己放置在问题上的标签上方,直到出现一个黑框,然后单击其中的信息链接。
Then scroll a bit down to JSTL versions information until you find download link to JSTL 1.2 (or 1.2.1).
然后向下滚动到 JSTL 版本信息,直到找到 JSTL 1.2(或 1.2.1)的下载链接。
Finally just drop exactly that file in webapp's /WEB-INF/lib.
最后只需将该文件放入 webapp 的/WEB-INF/lib.
This way the taglib declaration must not give any errors anymore and the JSTL tags and functionsshould just work.
这样 taglib 声明就不能再出现任何错误,JSTL 标签和函数应该可以正常工作。
回答by THIHA SOE
I just want to share my experience. I have same problem about jstl using maven. I resolved it by adding two dependency.
我只想分享我的经验。我对使用 maven 的 jstl 有同样的问题。我通过添加两个依赖项解决了它。
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
回答by pivopil
If you use Tomcat server I suggest you to put JSTL .jar file to the Tomcat lib folder. By doing this you will have an access to JSTL in all your web projects automatically (with taglib declaration in .jsp files of course).
如果您使用 Tomcat 服务器,我建议您将 JSTL .jar 文件放到 Tomcat lib 文件夹中。通过这样做,您将可以自动访问所有 Web 项目中的 JSTL(当然,在 .jsp 文件中使用 taglib 声明)。
回答by user2339071
This is a fix for people who are not using maven. You also need to add standard.jarto your lib folder for the core tag library to work. Works for jstl version 1.1.
这是对不使用 maven 的人的修复。您还需要将standard.jar核心标签库添加到您的 lib 文件夹中。适用于 jstl 1.1 版。
<%@taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core"%>
回答by Benoit Wickramarachi
You can download the Apache Standard Tagliband include the jar in your project.
您可以下载Apache Standard Taglib并将该 jar 包含在您的项目中。
回答by Aris Capellos
I was getting this problem with a maven project using the eclipse IDE. I changed the 'Order and Export' in the project's build path putting the Maven dependencies first and the error disappeared. I guess it's because the eclipse IDE was initially building my application source before loading the Maven libraries.
我在使用 Eclipse IDE 的 Maven 项目中遇到了这个问题。我更改了项目构建路径中的“Order and Export”,将 Maven 依赖项放在首位,错误消失了。我猜这是因为 Eclipse IDE 在加载 Maven 库之前最初构建了我的应用程序源。
回答by davidqwk
I was getting the same problem on
Spring Tool Suite 3.2 and changed the version of jstl to 1.2 (from 1.1.2) manually when adding it to the dependency list, and the error got disappeared.
我在
Spring Tool Suite 3.2上遇到了同样的问题,并在将其添加到依赖项列表时手动将 jstl 的版本更改为 1.2(从 1.1.2),并且错误消失了。

