找不到“http://java.sun.com/jsp/jstl/core”的标签库描述符 [英] Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”

查看:127
本文介绍了找不到“http://java.sun.com/jsp/jstl/core”的标签库描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把它放在了JSP页面的最上方:

 <%@ taglib prefix =c uri =http://java.sun.com/jsp/jstl/core%> 

我已将JSTL JAR文件放在 WEB-INF / / code>目录。但是,仍然,JSP无法解析taglib。我得到以下错误:


找不到您使用的是Tomcat 7.在这种情况下,您需要JSTL 1.2。但是,您有一个 jstl.jar 文件,而JSTL 1.2显示版本号包含如此 jstl-1.2.jar 。 JSTL 1.0和1.1的典型文件名为 jstl.jar 。该版本需要包含必需TLD文件的 / WEB-INF / lib 中的 standard.jar 。然而,在特定情况下, / WEB-INF / lib 中明确缺少 standard.jar ,那就是为什么taglib URI无法解决。



为了解决这个问题,你必须删除错误的JAR文件,下载 jstl-1.2.jar ,并将其全部放在 / WEB -INF / lib中。就这样。您不需要提取它,也不需要在项目的<生成路径中解开。



不要忘记删除这个松散的 c.tld 文件。它绝对不属于那里这在互联网其他地方的一些不好的教程或答案中确实是有指示的。这是由一个重大的误会和错误配置造成的神话。在类路径中永远不需要松动的JSTL TLD文件,也不需要在以前的JSTL版本中。



如果您使用Maven,请使用以下坐标:

 < dependency> 
< groupId> javax.servlet< / groupId>
< artifactId> jstl< / artifactId>
< version> 1.2< / version>
< / dependency>

您还应确保您的 web.xml 被声明为符合至少 Servlet 2.4,因此不会像Servlet 2.3或更旧版本。否则,JSTL标签中的EL表达式反过来将无法正常工作。选择与您的目标容器匹配的最高版本,并确保您的 web.xml中的任何位置都没有<!DOCTYPE> code>。这是一个Servlet 3.0(Tomcat 7)兼容的例子:

 <?xml version =1.0 encoding =UTF-8?> 
< web-app
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_3_0 .xsd
version =3.0>

<! - 在这里配置。 - >

< / web-app>



另请参见:




I have included this at the very top of my JSP page:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

I already placed the JSTL JAR file in the WEB-INF/lib directory. But still, the JSP can't resolve the taglib. I get the below error:

Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

I am using Eclipse Juno and the project structure is shown below:

解决方案

Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

Based on one of your previous questions you're using Tomcat 7. In that case you need JSTL 1.2. However, you've there a jstl.jar file while JSTL 1.2 has clearly the version number included like so jstl-1.2.jar. The sole filename jstl.jar is typical for JSTL 1.0 and 1.1. This version requires a standard.jar along in /WEB-INF/lib which contains the necessary TLD files. However, in your particular case the standard.jar is clearly missing in /WEB-INF/lib and that's exactly the reason why the taglib URI couldn't be resolved.

To solve this you must remove the wrong JAR file, download jstl-1.2.jar and drop it in its entirety in /WEB-INF/lib. That's all. You do not need to extract it nor to fiddle in project's Build Path.

Don't forget to remove that loose c.tld file too. It absolutely doesn't belong there. This is indeed instructed in some poor tutorials or answers elsewhere in the Internet. This is a myth caused by a major misunderstanding and misconfiguration. There is never a need to have a loose JSTL TLD file in the classpath, also not in previous JSTL versions.

In case you're using Maven, use the below coordinate:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

You should also make sure that your web.xml is declared conform at least Servlet 2.4 and thus not as Servlet 2.3 or older. Otherwise EL expressions inside JSTL tags would in turn fail to work. Pick the highest version matching your target container and make sure that you don't have a <!DOCTYPE> anywhere in your web.xml. Here's a Servlet 3.0 (Tomcat 7) compatible example:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
    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_3_0.xsd"
    version="3.0">

    <!-- Config here. -->

</web-app>

See also:

这篇关于找不到“http://java.sun.com/jsp/jstl/core”的标签库描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆