包含与Maven的JSTL依赖关系

fly*_*ire 32 java jsp servlets jstl maven

我正在使用maven2,如何向JSTL添加依赖项(JSP标准标记库)?

Jer*_*ian 33

上面提到的依赖关系对我来说还不够(使用Tomcat 5.x作为servlet容器,它本身不提供JSTL实现).它只是将相应的JSTL接口包导入到项目中,并将在Tomcat中导致运行时错误.

这是我的项目中使用的依赖部分,希望可以帮助其他人.最难的部分是在存储库中命名Apache的JSTL实现.

  <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>
Run Code Online (Sandbox Code Playgroud)


Sha*_*yan 31

您需要将它添加到您的pom.xml文件中.

在dependencies节点中,您需要添加对JSTL的引用.您可能需要将其范围设置为编译.所以它看起来像这样

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>"whatever version you need"</version>
  <scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这假设您在pom.xml或settings.xml中具有对maven分发存储库的正确引用