Java 在Maven中包含JSTL依赖项
我正在使用maven2,如何向JSTL(JSP标准标记库)添加依赖项?您需要将其添加到pom.xml文件中 在dependencies节点中,需要添加对JSTL的引用。您可能需要将其范围设置为编译。看起来是这样的Java 在Maven中包含JSTL依赖项,java,jsp,servlets,jstl,maven,Java,Jsp,Servlets,Jstl,Maven,我正在使用maven2,如何向JSTL(JSP标准标记库)添加依赖项?您需要将其添加到pom.xml文件中 在dependencies节点中,需要添加对JSTL的引用。您可能需要将其范围设置为编译。看起来是这样的 <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>"whatever versio
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>"whatever version you need"</version>
<scope>runtime</scope>
</dependency>
javax.servlet
jstl
“您需要的任何版本”
运行时
这是假设您在pom.xml或settings.xml中有对maven分发存储库的正确引用。上面提到的依赖项对我来说是不够的(使用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>
javax.servlet
jstl
1.1.1
运行时
塔格利布
标准
运行时
1.1.1
塔格利布
C
1.1.1
运行时
tld
塔格利布
fmt
1.1.1
运行时
tld
jstl
我也有同样的问题。我通过向Java构建路径添加ApacheTomcat库来解决这个问题
查看我的屏幕截图,我正在使用Maven:
在添加Tomcat库之前:
添加Tomcat库后:
来自:
org.apache.taglibs
taglibs标准规范
1.2.1
org.apache.taglibs
taglibs标准impl
1.2.1
沙兰
沙兰
2.7.1
沙兰
序列化程序
2.7.1
塔格利布
标准
1.1.2
javax.servlet
jstl
1.1.2
在过去几周左右的时间里,Maven JSTL依赖关系似乎至少从中央存储库中消失了。这在网络上引起了许多问题
Oracle已经发布了单独的API和实现依赖项,这正是它们应该被分解的方式。现在,您将使用以下内容,而不是一个javax.servlet.jstl依赖项:
<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>
javax.servlet.jsp.jstl
JSTLAPI
1.2
org.glassfish.web
jstl impl
1.2
这是有效的。@dcompiled我没有从Maven那里找到关于这个的官方文档,但我猜,tld代表“标记库描述符”,它本身就是XML文件。我使用的是tomcat 7,在接受的答案中给出的答案似乎对我来说已经足够了……1.1.2版和1.2版之间有一个微妙之处,雄猫和玻璃鱼。有关详细信息,请参见此处:应弃用jstl组id。改用javax.servlet。这是否也包括standard.jar
?我使用的是GlassFish,应该只包括jstl
依赖项工作吗?standard.jar
用于JSTL1.0。您绝对不应该将它包括在JSTL1.1或更新版本中。如果您这样做,EL可能会停止工作,因为它最初是JSTL1.0的一部分,后来被转移到JSP2.0中。
<!-- 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: -->
<!-- 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>
<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>