IntelliJ and JSP/JSTL cannot resolve taglib for JSTL in tomcat7

后端 未结 4 1086
谎友^
谎友^ 2020-11-28 10:37

First of all my JSTl code works on my server because i have the proper Jar file in the Lib folder in tomcat7. This is just really an IDEA problem. My questions comes down

相关标签:
4条回答
  • 2020-11-28 11:17

    If you are still getting errors after following the instructions provided by Shams UI Azeem, you may need to add the JSTL library to the WAR Exploded artifact. To do this:

    1. Go to Project Structure. Under Project Settings, select Artifacts. On the bottom of the menu box, there may be a message which mentions that the JSTL library used is not included in the WAR.

    2a. Message visible. If the message is displayed, there should be a Fix button next to it. Click this Fix button. Select "add javax.servlet:jstl:1.2 to the artifact".

    2b. Message not visible. If the message is not displayed, then look above to see if the javax.servet:jstl:1.2 (Project Library) is underneath the Available Elements column. If it is, right click it and select "Put into /WEB-INF/lib".

    If you are working with Maven, the Fix message will not appear, though you will still need to do this.

    0 讨论(0)
  • 2020-11-28 11:19

    First add this to the top of your .jsp file:

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

    It will still give syntax error but you can fix that by adding javax.servlet:jstl:1.2 as a module dependency. To do that, follow these steps:

    1. Click your project name and press F4 to bring up the module settings dialog.
    2. Then go to the dependencies tab in the modules section.
    3. Click the green + icon library From Maven.
    4. Search for javax.servlet:jstl:1.2 in the search bar and press OK and it will download and add the above mentioned library as a module.
    5. Now you should not have any kind of syntax error.
    0 讨论(0)
  • 2020-11-28 11:22

    If you are using maven, add following code in pom.xml inside the <dependencies></dependencies> tag

    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    
    0 讨论(0)
  • 2020-11-28 11:33

    Add below dependency to your pom.xml

    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题