![](/img/trans.png)
[英]<my:foo> Tag Library supports namespace: http://java.sun.com/jsf/composite/mycomponents, but no tag was defined for name: foo
[英]JSF 2.1.13 custom component not found: Tag Library supports namespace: <namsepace> but no tag was defined for name: <compositecomponent>
我正在使用JSF 2.1.13
創建一個原型來展示JSF對我們當前使用JSP
和struts 1.1
構建的webapp的好處。 我使用JSF 2.2.6
代碼跟蹤代碼,但是一旦我發現Oracle Weblogic 12c還不支持JSF 2.2,我就不得不降級。 使用2.1.13運行代碼時收到以下錯誤:
/pages/sites/tab-details.xhtml @27,90 <ccc:codedType> Tag Library supports namespace: http://java.sun.com/jsf/composite/ccc, but no tag was defined for name: codedType
谷歌搜索只指向我有關嵌套復合組件的錯誤 ,但這不是我正在做的事情。
pom.xml
<!-- JSF Dependencies -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
</dependency>
webapp/WEB-INF/resources/ccc/codedType.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface shortDescription="Renders a CodedType">
<cc:attribute name="value" required="true"
shortDescription="Instance of CodedType to be properly rendered"
type="company.prototype.uireplacement.presenter.CodedType" />
<cc:attribute name="includeCode"
shortDescription="Whether or not the rendeder type should include the code"
type="boolean" default="false"/>
</cc:interface>
<cc:implementation>
<span id="#{cc.attrs.id}">#{cc.attrs.value.label}<ui:fragment rendered="#{cc.attrs.includeCode}"> (#{cc.attrs.value.code})</ui:fragment></span>
</cc:implementation>
</ui:component>
webapp/pages/sites/tab-details.xhtml
: webapp/pages/sites/tab-details.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:ccc="http://java.sun.com/jsf/composite/ccc">
<ccc:codedType value="#{siteControllerBean.selectedSite.type}" includeCode="true"/>
</ui:composition>
經過多次挖掘后,我發現了導致我錯誤的原因。 請注意我的組件的位置: webapp/WEB-INF/resources/ccc/codedType.xhtml
。 適當的位置應該是webapp/resources/ccc/codedType.xhtml
(root vs WEB-INF
)。 在JSF 2.2中,他們允許位置可配置,我在web.xml
有以下內容:
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param>
這就是為什么事情在JSF 2.2中有效。
我的情況的修復是刪除javax.faces.WEBAPP_RESOURCES_DIRECTORY
因為它沒有在JSF 2.1中使用並將資源移動到根目錄。
我最近遇到了這個錯誤:請確保將模板放在位置src ../ META-INF / resources / myFolder並使用xmlns引用它:tp =“http://java.sun.com/jsf/composite/myFolder” >這幫助我解決了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.