开发者

How to add JSTL to Maven?

I'm working on a JSF 2.0 project using Mojarra, PrimeFaces and Tomcat 6.x.

I need to use c:forEach for some primefaces component like dynamic number of p:tab but i have problem with the c:forEach. All the other tag of JSTL work nice.

I have the following error :

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/LoopTagStatus

I use the following xmlns:c="http://java.sun.com/jsp/jstl/core", i tried to replace with xmlns:c="http://java.sun.com/jstl/core" but nothing display with the second.

This is the exact version of lib:

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.0.2-FCS</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.0.4-b03</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>2.2.1</version>
</dependency>

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>el-api</artifactId>
    <version>2.2</version>
</dependency>

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>el-impl</artifactId>
    <version>2.2</version>
</dependency>

How i can fix it ?

I can give more specific information if needed.

EDIT: I added and tried different scopes (runtime and compile) but nothing change:

<dependency>
    <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
</dependency>

The list of repository:

  <repositories>
    <repository>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <layout>default</layout>
      <url>http://repo1.maven.org/maven2</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>maven-repository.dev.java.net</id>
      <name>Java.net Repository for Maven 1</name>
      <url>http://download.java.net/maven/1/</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>maven2</id>
      <name>Java.net Repository for Maven</name>
      <url>http://download.java.net/maven/2</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>prime-repo</id>
      <name>Prime Technology Maven Repository</name>
      <url>http://repository.prime.com.tr</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>JBoss2</id>
      <url>https://repository.jboss.org/nexus/content/repositories/public</url>
    </repository>
    <repository>
      <id>JBoss</id>
      <url>http://repository.jboss.com/maven2</url>
    </repository>
    <repository>
      <id>EclipseLink Repo</id>
      <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>itextpdf.com</id>
      <name>Maven Repository for iText</name>
      <url>http://maven.itextpdf.com/</url>
    </repository>

    <repository>
      <id>guiceyfruit.release</id>
      <name>GuiceyFruit Release Repository</name>
      <url>http://guiceyfruit.googlecode.com/svn/repo/releases/</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </repositories>

This is the content of $TOMCAT_HOME/lib

annotations-api.jar catalina-ha.jar catalina-tribes.jar el-impl-2.2.jar jasper.jar jsf-api.jar

jsp-api.jar servlet-api.jar

tomcat-dbcp.jar

tomcat-i18n-fr.ja开发者_如何转开发r catalina-ant.jar

catalina.jar el-api-2.2.jar

jasper-el.jar jasper-jdt.jar

jsf-impl-2.0.4-b03.jar ojdbc6.jar

tomcat-coyote.jar tomcat-i18n-es.jar tomcat-i18n-ja.jar


You must include the jstl library in your distribution. This may be provided by the container, although that is not recommended practice. The maven dependency for the current version (as of writing) is here:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

Although, it's always worth checking the maven central repository for updates.


As Balus said, you just need to add JSTL to your pom.xml because Tomcat doesn't include it. 1.2 is the most recent version:

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
</dependency>


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

And then you can use the Java Standart Tags and Functions as follows in your jsp page:

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

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

This also works alone:

<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>


I know the question is old, but it's high in the Google results, so I'm adding this.

Newer JSTL version are available (only) under org.glassfish.web groupId. Example:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.servlet.jsp.jstl</artifactId>
    <version>1.2.5</version>
</dependency>

If you are looking for the Jakarta EE version:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>jakarta.servlet.jsp.jstl</artifactId>
    <version>2.0.0</version>
</dependency>


In recent Tomcat versions use:

<dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-spec</artifactId>
    <version>1.2.5</version>
</dependency>
<dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-impl</artifactId>
    <version>1.2.5</version>
</dependency>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜