Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

jstl - Standard way of adding JSLT 1.2.1 in a Maven Project?

What is the standard pom for adding the 1.2.1 JSTL taglib in a maven project. Any recommendations as to when/if can this be scoped as provided ? Any server peculiarities (interested in Jboss 7, Glassfish 4 and/or Tomcat 7)

EDIT: Added:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.servlet.jsp.jstl</artifactId>
    <version>1.2.1</version>
    <scope>provided</scope>
</dependency>

This adds:

enter image description here

Notice it transitively adds the 1.2 api.

I am using provided as I am using Jboss which should provide it: Basic question complicated solution - Tomcat to JBoss. Still this is the 1.2 api apparently

$ find . -name *jstl*.jar
./modules/javax/servlet/jstl/api/main/jboss-jstl-api_1.2_spec-1.0.2.Final.jar

(contains implementation also). So would the correct way be to add the jstl jars to the pom (not in provided scope) and mark the servlet-api (I'm on 3 anyway) as provided somehow ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ended up using :

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>
<!-- Add the jstl-api dependency explicitly - otherwise jstl-api 1.2 is added -->
<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>javax.servlet.jsp.jstl-api</artifactId>
    <version>1.2.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.servlet.jsp.jstl</artifactId>
    <version>1.2.1</version>
    <exclusions>
         <!-- jstl-api was adding selvlet-api 2.5 and jsp-api-->
        <exclusion>
            <artifactId>jstl-api</artifactId>
            <groupId>javax.servlet.jsp.jstl</groupId>
        </exclusion>
    </exclusions>
</dependency>

Not sure if I should add the jstl-api dependency - please comment (I would accept a more authoritative answer actually). Result:

enter image description here

See:

For 1.2:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...