简体   繁体   中英

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

I am getting the error above at line

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

As dependency I have

<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>

and build:

<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>

And finally my 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>

I already read following question but couldn't get the error to disappear:

I am running Tomcat 9.0.8. What could cause this error and how can I fix it?

Try with below maven dependancy.

 <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>

So I found the answer myself. I didn't have to change my POM or anything at all. What I had to do was to activate the Project Facets and select Tomcat as runtime.

Right Click on project -> Properties -> Project Facets -> Check: Dynamic Web Module, Java and JavaScript -> Hit the Runtimes tab on the right and check Tomcat server

This solved a few errors already. The last part was to deploy the maven dependencies with the project. For this you will have to go to:

Right Click on project -> Properties -> Deployment Assembly -> Add... -> Java Build Path Entries -> Select (all) entries and hit Finish

Those were the steps I had to take to run my web project properly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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