我正在使用maven2,如何向JSTL(JSP標準標記庫)添加依賴項?包含JSTL對Maven的依賴關係
回答
您需要將其添加到您的pom.xml文件中。
在依賴關係節點中,您需要添加對JSTL的引用。您可能需要將其範圍設置爲編譯。因此,這將是這個樣子
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>"whatever version you need"</version>
<scope>runtime</scope>
</dependency>
這是假設你在你的pom.xml或settings.xml中的行家分佈存儲庫中的適當引用
這是否也包括'standard.jar'?我正在使用GlassFish,應該只包括'jstl'依賴項工作? – 2016-02-10 18:41:15
上面提到的依賴關係是不夠的,我(使用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>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
jstl組ID應該被棄用。 改爲使用
我有同樣的問題。我通過將Apache Tomcat庫添加到Java構建路徑來解決此問題。
見我的截圖,我使用Maven:
增加Tomcat的庫之前:
加入Tomcat的庫後:
來源: apache taglib
<!-- 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>
- 1. Maven-Assembly-Plugin包含特定的依賴關係及其傳遞依賴關係
- 2. Intellij-idea模塊依賴關係不包含內部maven依賴關係
- 3. Maven依賴關係
- 4. Maven依賴關係
- 5. 依賴的Maven副本依賴關係
- 6. 對Maven的依賴關係的NoClassDefFoundError
- 7. Maven測試jar包括依賴關係
- 8. maven包快照依賴關係?
- 9. maven不重新包裝依賴關係
- 10. maven:不包括模塊依賴關係
- 11. AbstractHandler的Maven依賴關係
- 12. sqlserver2010的maven依賴關係?
- 13. LibreOffice Maven的依賴關係?
- 14. maven依賴關係的API
- 15. com.day.util的Maven依賴關係
- 16. WAR對maven的依賴關係
- 17. Maven對MySQL的依賴關係
- 18. 對於GeneratedMockFactory的Maven依賴關係
- 19. 父項目包含常見的Maven依賴關係
- 20. Cassandra 3.7上的Spark 2.0 - 包含哪些Maven依賴關係?
- 21. 我是否需要包含hibernate.jar的所有Maven依賴關係?
- 22. 使用maven-bundle-plugin包含來自Spring XML的依賴關係
- 23. 在Maven中隱式包含可選的依賴關係
- 24. C - 編譯包含的依賴關係
- 25. 如何包含dr.js的依賴關係?
- 26. maven程序集 - 忽略zip依賴關係的依賴關係
- 27. Zest Eclipse Maven依賴關係
- 28. Grails依賴關係或Maven
- 29. 碼頭maven依賴關係
- 30. Pentaho maven/gradle依賴關係
版本1.1.2,版本1.2,Tomcat和GlassFish之間有一個微妙之處。詳情請看這裏:http://tshikatshikaaa.blogspot.nl/2012/07/how-to-add-jslt-taglibs-in-maven-project.html – JVerstry 2012-07-27 17:55:44