Include JSTL dependency with Maven

后端 未结 7 1448
梦谈多话
梦谈多话 2020-12-24 11:51

I am using maven2, how do I add a dependency to JSTL (The JSP Standard Tag Library) ?

相关标签:
7条回答
  • 2020-12-24 12:20

    From: apache taglib

            <!-- TAGLIB: --> 
              <dependency>
              <groupId>org.apache.taglibs</groupId>
              <artifactId>taglibs-standard-spec</artifactId>
              <version>1.2.1</version>
            </dependency>
    
            <dependency>
              <groupId>org.apache.taglibs</groupId>
              <artifactId>taglibs-standard-impl</artifactId>
              <version>1.2.1</version>
            </dependency>  
                <!-- From taglib doc: To use this distribution with your own web applications, add the following JAR
                    files to the '/WEB-INF/lib' directory of your application:
                       - taglibs-standard-spec-1.2.1.jar
                       - taglibs-standard-impl-1.2.1.jar
                       - taglibs-standard-jstlel-1.2.1.jar
                       - xalan-2.7.1.jar
                       - serializer-2.7.1.jar
                -->
            <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>2.7.1</version>
        </dependency>
    
            <dependency>
            <groupId>xalan</groupId>
            <artifactId>serializer</artifactId>
            <version>2.7.1</version>
        </dependency>
        <!-- TAGLIB: -->
    
    0 讨论(0)
  • 2020-12-24 12:29

    I had the same problem. I solved it by adding Apache Tomcat libraries to the Java build path.

    See my screenshots, I am using Maven:

    Before adding Tomcat libraries:

    desc

    After adding Tomcat libraries:

    desc

    0 讨论(0)
  • 2020-12-24 12:29
    <!-- standard.jar --> 
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>
    
    <!-- JSTL --> 
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>
    
    0 讨论(0)
  • 2020-12-24 12:32

    The dependencies mentioned above is not enough for me(using Tomcat 5.x as servlet container, which doesn't provide JSTL implementation itself). It just imports the according JSTL interface package into project, and will cause a runtime error in Tomcat.

    Here is the dependency part used in my project, hopefully can help others out. The hardest part is the naming of the Apache's JSTL implementation in repository.

      <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.1</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <scope>runtime</scope>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>c</artifactId>
            <version>1.1.1</version>
            <scope>runtime</scope>
            <type>tld</type>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>fmt</artifactId>
            <version>1.1.1</version>
            <scope>runtime</scope>
            <type>tld</type>
        </dependency>
    
    0 讨论(0)
  • 2020-12-24 12:32
    <dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    </dependency>
    

    http://mvnrepository.com/artifact/jstl/jstl/1.2

    0 讨论(0)
  • 2020-12-24 12:33

    It seems in the last few weeks or so the Maven JSTL dependency has vanished from at least the central repository. This has caused a number of issues around the web.

    Oracle has released the separate API and implementation dependencies which is really how they should be broken down. Now, instead of having one javax.servlet.jstl dependency you will use the following:

    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>jstl-api</artifactId>
        <version>1.2</version>
    </dependency>
    
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>jstl-impl</artifactId>
        <version>1.2</version>
    </dependency>
    

    And this works.

    0 讨论(0)
提交回复
热议问题