无法将具有公共ID和基本URI tomcat / lib / jstl-1.2的XML资源[null]解析为已知的本地实体

问题描述 投票:1回答:1

运行Tomcat时出现此错误:

ublic ID and base

[我在jstl-1.2.jar中添加了tomcat/webapps之后发生了。我必须这样做,因为我得到了

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

对于具有的jsp

<c:forEach items="${requestScope.users}" var="user" varStatus="loop">
                        <tr class="user"  >
                            <td>${user.getFirstName()}</td>
                            <td class="item-name">${user.getLastName()}</td>
                            <td>${user.getEmail()}</td>
                            <td>${user.getAge()}</td>
                        </tr>
                </c:forEach>

(这就是所有SO答案所建议的内容。

我也有


        <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

在我的pom.xml中。

整个jsp:

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

<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'/>
    <title>Some Web Page</title>

    <%@ include file = "/WEB-INF/views/shared/meta.jsp" %>

</head>
<body>

<%@ include file = "/WEB-INF/views/shared/header.jsp" %>



<br/><br/><br/>
<div class = "home_panel">
    <div class="table-container all-users-table">
            <table class = "table" style="width:100%">
                <thread>
                <tr>
                    <th>First name</th>
                    <th>Last name</th>
                    <th>Email</th>
                    <th>Age</th>
                    <th>Gender</th>
                </tr>
                </thread>

                <c:forEach items="${requestScope.users}" var="user" varStatus="loop">
                        <tr class="user"  >
                            <td>${user.getFirstName()}</td>
                            <td class="item-name">${user.getLastName()}</td>
                            <td>${user.getEmail()}</td>
                            <td>${user.getAge()}</td>
                            <td>${user.getGender().name().toLowerCase()}</td>
                        </tr>
                </c:forEach>

            </table>
    </div>

    <div class="table-container videos-container">
        <table class = "all-videos-table" style="width:100%">
            <tr>
                <th>Title</th>
                <th>Description</th>
                <th>URL</th>
                <th>Added by</th>
                <th>Posting date</th>
                <th>Tags</th>
            </tr>
            <tr>
                <td>Title</td>
                <td>Description</td>
                <td>
                    <div class = "video-link dark-button" onclick="">
                        https://youtube.com
                    </div>
                </td>
                <td>Jon</td>
                <td>22/03/20</td>
                <td>
                    <div class="tags-container">
                        <div class="red-button tag">
                            funny
                        </div>
                        <div class="red-button tag">
                            nature
                        </div>
                        <div class="red-button tag">
                            animals
                        </div>
                    </div>
                </td>
            </tr>

        </table>
    </div>
    <iframe width="560" height="315" src="https://www.youtube.com/embed/xV83h4A9a9w"
            frameborder="0" allow="accelerometer;
            autoplay; encrypted-media;
            gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>

</body>

</html>

我尝试添加此web.xml:

<?xml version="1.0" encoding="UTF-8" ?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

    <display-name>comediansappf</display-name>
    <description>
        Comedy videos app
    </description>

    <context-param>
        <param-name>appname</param-name>
        <param-value>comediansappf</param-value>
    </context-param>





</web-app>

但仍然得到其中一个

enter image description here

enter image description here

如果我多次更新页面。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>automotivepartsapp</groupId>
    <artifactId>automotivepartsapp</artifactId>
    <version>1.0-SNAPSHOT</version>


    <packaging>war</packaging>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>


    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-impl</artifactId>
            <version>1.2.5</version>
        </dependency>


        <!-- Add support for JSP ... get rid of Eclipse error -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-war-plugin -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.12.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.16</version>
        </dependency>



    </dependencies>

    <!-- Support for Maven WAR Plugin -->

    <build>
        <finalName>comedianswar2</finalName>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.0</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

enter image description here

java spring-boot jsp tomcat jstl
1个回答
0
投票

从tomcat / lib中删除jstl-1.2.jar。>

您的情况下不需要web.xml

尝试一下:

  1. pom.xml中添加此依赖项:

    <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>jstl-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.apache.taglibs</groupId> <artifactId>taglibs-standard-impl</artifactId> <version>1.2.5</version> </dependency>

  2. 进行Maven清洁,然后进行Maven安装或Maven软件包以产生适当的war / jar。

尝试在Tomcat上运行项目。

我希望它应该没有错误。

© www.soinside.com 2019 - 2024. All rights reserved.