【问题标题】:JSP error "Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"JSP 错误“找不到“http://java.sun.com/jsp/jstl/core”的标记库描述符
【发布时间】:2018-11-22 19:34:28
【问题描述】:

我在第

行收到了上面的错误
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

作为依赖我有

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>

并构建:

<build>
    <finalName>test-jsp</finalName>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webXml>WebContent\WEB-INF\web.xml</webXml>
                <warSourceDirectory>WebContent</warSourceDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

最后是我的 webapp.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="WebApp_ID" version="3.1">
    <display-name>JSPTest</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>    
</web-app>

我已经阅读了以下问题,但无法让错误消失:

我正在运行 Tomcat 9.0.8。什么可能导致此错误,我该如何解决?

【问题讨论】:

    标签: java jsp jstl


    【解决方案1】:

    尝试使用以下 maven 依赖项。

     <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
       <version>1.2</version>
     </dependency>
     <dependency>
     <!-- This can be ignored -->
     <groupId>org.apache.tomcat</groupId>
         <artifactId>tomcat-jasper</artifactId>
         <version>9.0.8</version>
      </dependency>
    
            <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
    

    【讨论】:

    • 这确实有效,但现在我收到错误 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 并将 URI 更改为 http://java.sun.com/jstl/core 也没有帮助。 This question 建议使用&lt;dependency&gt; &lt;groupId&gt;javax.servlet&lt;/groupId&gt; &lt;artifactId&gt;jstl&lt;/artifactId&gt; &lt;version&gt;1.2&lt;/version&gt; &lt;/dependency&gt;
    • 我无权访问我的系统来测试和更新你,但是还有额外的 maven 依赖项要添加,如果在接下来的 2 小时内没有另一个答案,那么我可以检查它并发表评论。跨度>
    • 添加了 tomcat-jasper 依赖
    • 我没有测试,因为我已经找到了解决方案
    【解决方案2】:

    所以我自己找到了答案。我根本不需要改变我的 POM 或任何东西。我要做的是激活Project Facets 并选择Tomcat 作为运行时。

    右击项目 -> 属性 -> 项目构面 -> 勾选:Dynamic Web Module, Java and JavaScript -> 点击右侧的 Runtimes 选项卡,勾选 Tomcat 服务器

    这已经解决了一些错误。最后一部分是在项目中部署 maven 依赖项。为此,您必须前往:

    右键单击项目 -> 属性 -> 部署程序集 -> 添加... -> Java 构建路径条目 -> 选择(所有)条目并点击完成

    这些是我正确运行我的网络项目所必须采取的步骤

    【讨论】:

      猜你喜欢
      • 2013-03-04
      • 1970-01-01
      • 2011-08-24
      • 2015-03-07
      • 2021-08-27
      • 2011-04-27
      • 2015-02-09
      • 2011-09-13
      相关资源
      最近更新 更多