繁体   English   中英

JSP错误“找不到“ http://java.sun.com/jsp/jstl/core”的标记库描述符

[英]JSP error “Can not find the tag library descriptor for ”http://java.sun.com/jsp/jstl/core"

我在行上面收到错误

<%@ 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。 是什么导致此错误,我该如何解决?

尝试以下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>

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

右键单击项目->属性->项目构面->检查:动态Web模块,Java和JavaScript->单击右侧的Runtimes选项卡并检查Tomcat服务器

这样已经解决了一些错误。 最后一部分是在项目中部署Maven依赖项。 为此,您将必须转到:

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

这些是我必须执行的正确运行Web项目的步骤

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM