简体   繁体   English

Apache Tomcat 10.0.0-M1 使用 JSP Absolute uri http://java.sun.com/jsp/jstl/core 无法解析

[英]Apache Tomcat 10.0.0-M1 using JSP Absolute uri http://java.sun.com/jsp/jstl/core cannot be resolved

I have tried everything in the multiple threads on this site (non of them were for Tomcat 10 and non of the solved problem. I am using Apache NetBeans 11.1 with Apache Tomcat 10.0.0-M1. Below is my configuration -- if I remove the taglib line from my jsp file, the error goes away.我已经尝试了该站点上多个线程中的所有内容(它们都不是用于 Tomcat 10,也不是已解决的问题。我将 Apache NetBeans 11.1 与 Apache Tomcat 10.0.0-M1 一起使用。以下是我的配置——如果我删除我的 jsp 文件中的 taglib 行,错误消失了。

web.xml:网页.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">

    <!-- Config here. -->

</web-app>

pom.xml dependencies: pom.xml 依赖项:

<dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>8.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20190722</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
            <type>jar</type>
        </dependency>
        <dependency>
           <groupId>com.zaxxer</groupId>
           <artifactId>HikariCP</artifactId>
           <version>3.3.1</version>
           <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.1.10.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.1.10.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <!--scope>provided</scope-->
        </dependency>
    </dependencies>

test.jsp测试.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>

    </head>
    <body>
        <h1>Test Results</h1>
        <testResults></testResults>
    </body>
</html>

error displayed:显示错误:

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:55)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:294)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:81)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:251)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:122)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:431)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:489)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1445)
    org.apache.jasper.compiler.Parser.parse(Parser.java:144)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:105)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:206)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:386)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:605)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    jakarta.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:955)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:128)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
    jakarta.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    jakarta.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

I found out that on Tomcat 10 you can use apache-taglibs 1.2.5 migrated with tomcat migration tool with jakarta-jstl-api 2.0, or use glassfish jstl implementation, that works just fine.我发现在 Tomcat 10 上,您可以使用通过 jakarta-jstl-api 2.0 的 tomcat 迁移工具迁移的 apache-taglibs 1.2.5,或者使用 glassfish jstl 实现,效果很好。

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>jakarta.servlet.jsp.jstl</artifactId>
    <version>2.0.0-M1</version>
</dependency>

The Apache Tomcat team gave me the solution via e-mail (Thanks Mark): Apache Tomcat 团队通过电子邮件给了我解决方案(感谢 Mark):

From the Tomcat 10.0.0-M1 release announcement:来自 Tomcat 10.0.0-M1 发布公告:

Users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax.* to jakarta.*. Tomcat 10 以后的用户应该知道,作为 Java EE 向 Eclipse Foundation 转移的一部分,从 Java EE 转移到 Jakarta EE,所有已实现的 API 的主要包已从 javax.* 更改为 jakarta .*. This will almost certainly require code changes to enable applications to migrate from Tomcat 9 and earlier to Tomcat 10 and later.这几乎肯定需要更改代码才能使应用程序从 Tomcat 9 及更早版本迁移到 Tomcat 10 及更高版本。

 <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>8.0.1</version> <scope>provided</scope> </dependency>

That is never going to work on Tomact 10. You can't use Java EE 8 libraries with a Jakarta EE 9 server.这在 Tomact 10 上永远行不通。您不能在 Jakarta EE 9 服务器上使用 Java EE 8 库。

 <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.7</version> <type>jar</type> </dependency>

That needs to be replaced with Jakarta Mail (there might be an RC for that on Maven Central)这需要用 Jakarta Mail 替换(Maven Central 上可能有一个 RC)

 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.1.10.RELEASE</version> </dependency>

That won't work and, as far as I am aware, there is no Jakarta EE 9 version available (or even being worked on) yet.那是行不通的,据我所知,目前还没有可用的 Jakarta EE 9 版本(甚至正在开发中)。

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

You need the Jakarta Standard Tag Library 2.0 or later.您需要 Jakarta Standard Tag Library 2.0 或更高版本。 I think that is one of the Jakarta projects struggling for active committers.我认为这是为积极提交者而奋斗的雅加达项目之一。

Tomcat 10 ships with an API and implementation for the Jakarta Standard Tag Library 2.0 in the examples web application. Tomcat 10 在示例 Web 应用程序中附带了 Jakarta 标准标签库 2.0 的 API 和实现。 It was created by taking the JSTL 1.2 JARs and running them through Tomcat's Java EE 8 to Jakarta EE 9 conversion / migration tool.它是通过采用 JSTL 1.2 JAR 并通过 Tomcat 的 Java EE 8 到 Jakarta EE 9 转换/迁移工具运行它们而创建的。

test.jsp测试.jsp

Might sticking with Tomcat 9 be a better option for you for now?现在坚持使用 Tomcat 9 对你来说可能是一个更好的选择吗?

Mark标记

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 绝对URI:无法解析http://java.sun.com/jsp/jstl/core - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved Jetty 9.0 绝对uri:http://java.sun.com/jsp/jstl/core 无法解析 - Jetty 9.0 The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved 绝对URI:[http://java.sun.com/jsp/jstl/core]无法解决错误 - The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved error 绝对的uri:http://java.sun.com/jsp/jstl/core无法在web.xml或使用此应用程序部署的jar文件中解析 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this app 绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或tomcat中与此应用程序错误一起部署的jar文件中解决 - Absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application error in tomcat 在Eclipse WTP中从Tomcat 7迁移到8:绝对uri:http://java.sun.com/jstl/core无法解析 - Migrating from Tomcat 7 to 8 in Eclipse WTP: The absolute uri: http://java.sun.com/jstl/core cannot be resolved JSTL错误:绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或与此应用程序一起部署的jar文件中解析 - JSTL error: 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 JSTL:绝对uri:无法在web.xml或与此应用程序一起部署的jar文件中解析http://java.sun.com/jsp/jstl/core - JSTL: 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 错误HTTP状态500-绝对URI:无法在web.xml或jar文件中解析http://java.sun.com/jsp/jstl/core - Error HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files JBoss 6x绝对uri:http://java.sun.com/jsp/jstl/core不能在web.xml或与此应用程序一起部署的jar文件中解析 - JBoss 6x 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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM