How to use taglibs JSTL/core with JAR in WEB

Currently I have taglibs set up and working correctly using the following tag at the top of my JSP pages:

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

In Maven I have the dependencies:

<dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
    </dependency>

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

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency> 

I need my web app to work without Internet connection ie not calling the URI in the taglib so I thought I could download the jstl-1.2.jar and put it in /WEB-INF/lib folder. Then I could have my tag as the following:

<%@ taglib uri="/WEB-INF/lib/jstl-1.2" prefix="c" %>

However, this is not working. It says that the tag library descriptor cannot be found. So my question is, how do I use JSTL in taglibs using a JAR in the WEB-INF folder, instead of calling the java sun website in the URI??

Do I need to put anything in web.xml? Do I remove my Maven dependencies? Do I need to put something in META-INF?

Any help would be much appreciated! Thanks!


The URI in

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

is not really a reference to the internet. Even after putting the Jar file in WEB-INF/lib/ you will leave the uri as that address. The servlet container is always looking for the jar in WEB-INF/lib/ and never downloads it from http://java.sun.com/jsp/jstl/core . That URI is more like a unique name identifying the taglib.

Check for yourself by clicking the link to http://java.sun.com/jsp/jstl/core There is no jar file to download there. Its just an identifier.

链接地址: http://www.djcxy.com/p/74684.html

上一篇: Eclipse Maven中的Taglib问题

下一篇: 如何在WEB中使用带JAR的taglibs JSTL / core