![](/img/trans.png)
[英]Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”
[英]Java EE 7 : Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”
我試圖在我的JSP頁面中使用以下標記庫:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
但是Eclipse向我顯示了此錯誤:
Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
我已經使用此依賴項在我的類路徑中有了JSTL:
<dependency>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
我使用WildFly 9。
我對這兩個其他taglib有相同的問題:
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
備注 :以下鏈接給出了404 HTTP錯誤: http : //central.maven.org/maven2/javax/servlet/jsp/jstl/jstl/1.2/jstl-1.2.jar
謝謝。
如果您的Web應用程序直接使用JSTL,則對於JSTL 1.0,名稱空間為http://java.sun.com/jstl/core 。 在JavaEE 5中,包含JSTL 1.1,名稱空間為http://java.sun.com/jsp/jstl/core 。 在JaveEE 6和JavaEE 7中,包括JSTL 1.2,名稱空間為http://java.sun.com/jsp/jstl/core 。
但是,如果您的Web應用程序使用JSF + Facelets,則對於JaveEE 5中的JSF 1.x + Facelets 1.x,名稱空間為http://java.sun.com/jstl/core 。 對於JavaEE 6中的JSF 2.0 + Facelets 2.x,名稱空間為http://java.sun.com/jsp/jstl/core 。 對於JavaEE 7中的JSF 2.2 + Facelets 2.2,名稱空間為http://xmlns.jcp.org/jsp/jstl/core 。
Java EE 7教程在“ 什么是Facelets”部分中將JSTL的新URI簡要說明為:
但是,我還沒有找到使用URI的taglib的實現。 因此,URI(及其推薦的命名空間)應定義為:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
為了擺脫錯誤,您需要在provided
范圍內將JSTL的實現加載為依賴項,例如
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
所provided
作用域可防止將它包含在WAR文件中,因為應使用應用程序服務器正在使用的范圍。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.