绝对 uri:http://java.sun.com/jsp/jstl/core 无法在 web.xml 或使用此应用程序部署的 jar 文件中解析

发布于 2024-12-24 02:29:46 字数 2532 浏览 0 评论 0原文

我正在使用 JDK 1.7、Apache Tomcat 7.0.23,并且我已将 JSTL 核心库(1.2) 和 STANDARD jar 放在 WEB_INF lib 文件夹中,它没有给我任何警告,但当我尝试运行代码时,

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Create Bean Instance-->
<jsp:useBean id="listdomain" class="bean.PopulateMultiDomain" scope="session"></jsp:useBean>

<jsp:setProperty property="*" name="listdomain"/>

<c:forEach var="item" items="${listdomain.status}">
    <option>
        <c:out value="${item}" />
    </option>
</c:forEach> 

它给我以下错误:

org.apache.jasper.JasperException: 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
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:56)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:410)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:117)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:311)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:152)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:410)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1425)
    org.apache.jasper.compiler.Parser.parse(Parser.java:138)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

谁能告诉我我犯了什么错误?

I am using JDK 1.7, Apache Tomcat 7.0.23 and I have placed JSTL core library(1.2) and STANDARD jar in WEB_INF lib folder it is not giving me any warning but when I will try to run the code

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Create Bean Instance-->
<jsp:useBean id="listdomain" class="bean.PopulateMultiDomain" scope="session"></jsp:useBean>

<jsp:setProperty property="*" name="listdomain"/>

<c:forEach var="item" items="${listdomain.status}">
    <option>
        <c:out value="${item}" />
    </option>
</c:forEach> 

it gives me the following error:

org.apache.jasper.JasperException: 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
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:56)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:410)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:117)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:311)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:152)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:410)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1425)
    org.apache.jasper.compiler.Parser.parse(Parser.java:138)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Can anyone suggest me what mistake I am making?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

梦明 2024-12-31 02:29:46

删除standard.jar。当 TLD URI 没有 /jsp 路径时,它显然是旧的 JSTL 1.0 版本。 JSTL 1.2 可用此处您根本不需要 standard.jar 。只需 /WEB-INF/lib 中的 jstl-1.2.jar 就足够了。

另请参阅:

Remove the standard.jar. It's apparently of old JSTL 1.0 version when the TLD URIs were without the /jsp path. With JSTL 1.2 as available here you don't need a standard.jar at all. Just the jstl-1.2.jar in /WEB-INF/lib is sufficient.

See also:

找个人就嫁了吧 2024-12-31 02:29:46

我解决了同样的问题。我刚刚将 JSTL-1.2.jar 添加到 /apache-tomcat-xxx/lib 并将范围设置为在 maven pom.xml 中提供:

 <dependency>
     <groupId>jstl</groupId>
     <artifactId>jstl</artifactId>
     <version>1.2</version>
     <scope>provided</scope>
 </dependency>

I solved the same problem. I've just added JSTL-1.2.jar to /apache-tomcat-x.x.x/lib and set scope to provided in maven pom.xml:

 <dependency>
     <groupId>jstl</groupId>
     <artifactId>jstl</artifactId>
     <version>1.2</version>
     <scope>provided</scope>
 </dependency>
眼睛会笑 2024-12-31 02:29:46

确保您没有跳过

tomcat.util.scan.StandardJarScanFilter.jarsToSkip

Tomcat catalina.properties 中的所有 jar。

Make sure you didn't skip all jars in

tomcat.util.scan.StandardJarScanFilter.jarsToSkip

in Tomcat catalina.properties.

看海 2024-12-31 02:29:46

我已经删除了范围,然后使用 Maven 更新来解决这个问题。

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    **<!-- <scope>provided</scope> -->**
</dependency>

tomcat lib 文件夹中不存在 jstl lib。因此我们必须包含它。
我不明白为什么我们被告知要保留所提供的 servlet-api 和 jstl 的范围。

I have removed the scope and then used a maven update to solve this problem.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    **<!-- <scope>provided</scope> -->**
</dependency>

The jstl lib is not present in the tomcat lib folder.So we have to include it.
I don't understand why we are told to keep both servlet-api and jstl's scope as provided.

沦落红尘 2024-12-31 02:29:46

有问题的错误也可能是由禁用 JarScannertomcat/conf/context.xml 中。

另请参阅从 Tomcat 8.0.39 升级到 8.0.41 会导致“扫描失败”错误

可以避免这两个问题。

The error in question may also be caused by disabled JarScanner in tomcat/conf/context.xml.

See also Upgrade from Tomcat 8.0.39 to 8.0.41 results in 'failed to scan' errors.

<JarScanner scanManifest="false"/> allows to avoid both problems.

GRAY°灰色天空 2024-12-31 02:29:46

如果您使用 spring boot,请在 application.propertiese 中检查此属性是否已注释或删除(如果存在)。

server.tomcat.additional-tld-skip-patterns=*.jar

if you use spring boot check in application.propertiese this property is commented or remove it if exist.

server.tomcat.additional-tld-skip-patterns=*.jar

时光与爱终年不遇 2024-12-31 02:29:46

如果您使用 Eclipse 和 Maven 来处理依赖项,则可能需要采取这些额外步骤来确保 Eclipse 正确复制依赖项 Maven 依赖项在 WEB-INF/lib 中不可见(即动态 Web 应用程序的部署程序集)

If you are using eclipse and maven for handling dependencies, you may need to take these extra steps to make sure eclipse copies the dependencies properly Maven dependencies not visible in WEB-INF/lib (namely the Deployment Assembly for Dynamic web application)

凉栀 2024-12-31 02:29:46

这可能是因为传递依赖。

尝试在 JSTL 库中添加/删除范围。

这对我有用!

This might be because of the transitive dependencies.

Try to add/ remove the scope from the JSTL library.

This worked for me!

世界等同你 2024-12-31 02:29:46

如果您使用的是 Maven 项目,那么您只需在依赖项中添加 jstl-1.2 jar 即可。如果您只是将 jar 添加到您的项目中,那么 jar 文件可能不会添加到您的项目项目工件中。您只需将 jar 文件添加到 WEB-INF/lib 文件中即可。

输入图片此处的描述

这是当 jstl 未添加到工件时您的项目应该是什么样子。只需点击修复按钮,intellij 就会将 jar 文件添加到上述路径中。运行项目然后砰的一声。

If you are using maven project then you just need to add the jstl-1.2 jar in your dependency. If you are simply adding the jar to your project then it's possible that jar file is not added in your project project artifact. You simply need to add the jar file in WEB-INF/lib file.

enter image description here

This is how your project should look when jstl is not added to the artifact. Just hit the fix button and intellij will add the jar file in the above mentioned path. Run the project and bang.

别把无礼当个性 2024-12-31 02:29:46

我遇到了同样的问题,为了解决它,我在 pom.xml 中添加了以下条目并执行了 maven 更新

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

I was facing the same issue, to solve it I have added the below entry in pom.xml and performed a maven update.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文