java - Eclipse + JSF + Facelets + 复合组件 = CANNOT_FIND_FACELET_TAGLIB

标签 java eclipse jsf-2 facelets composite-component

我正在尝试将复合组件添加到我的 JSF Facelets 应用程序。

复合组件(email.xhtml)如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:h="http://java.sun.com/jsf/html">

<h:head>
    <title>This content will not be displayed</title>
</h:head>
<h:body>
    <composite:interface>
        <composite:attribute name="value" required="false" />
    </composite:interface>

    <composite:implementation>
        <h:outputLabel value="Email id: "></h:outputLabel>
        <h:inputText value="#{cc.attrs.value}"></h:inputText>
    </composite:implementation>
</h:body>
</html>

使用页面(emailuserpage.xhtml)如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:em="http://java.sun.com/jsf/composite/emcomp/">

<h:head>
    <title>Using a sample composite component</title>
</h:head>

<body>
    <h:form>
        <em:email value="my@email.address" />
    </h:form>
</body>
</html>

我的复合组件的路径是 src/main/webapp/resources/emcomp/email.xhtml。 我的用户页面的路径是 src/main/webapp/emailuserpage.xhtml

但我在 emailuserpage.xhtml 中同时收到编译时和运行时警告,并且浏览器中没有显示任何内容(除了警告消息)

Eclipse JSF HTML 编辑器中显示的编译时警告:

xmlns:em="http://java.sun.com/jsf/composite/emcomp/"
NLS missing message: CANNOT_FIND_FACELET_TAGLIB in: 
 org.eclipse.jst.jsf.core.validation.internal.facelet.messages

Eclipse 浏览器中显示的运行时警告(javax.faces.PROJECT_STAGE=web.xml 中的开发):

Warning: The page /emailuserpage.xhtml declares namespace http://java.sun.com/jsf/composite/emcomp/ and uses the tag em:email , but no TagLibrary associated to namespace.

这个问题我已经看过了(没有解决问题):NLS missing message: CANNOT_FIND_FACELET_TAGLIB

我正在使用 Eclipse 版本的 m2em2e-wtp 插件:

Eclipse Java EE IDE for Web Developers
Version: Indigo Service Release 2
Build id: 20120216-1857

对我做错了什么有什么想法吗? 我是否以某种方式错误地包含了复合组件,或者我是否使用了错误的目录来存储我的资源? 这是 Eclipse/配置问题吗?

[编辑]

回应丹尼尔的评论

源目录结构:

  • 项目/src/main/
    • Java/
    • 网络应用/

部署目录结构:

  • 项目
    • HTML 文件
    • resources/(包括emcomp/文件夹)
    • 元信息/
    • WEB-INF/(配置文件和 lib/文件夹)

最佳答案

从 XML namespace URI 中删除尾部斜杠。

xmlns:em="http://java.sun.com/jsf/composite/emcomp"

关于java - Eclipse + JSF + Facelets + 复合组件 = CANNOT_FIND_FACELET_TAGLIB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10205992/

相关文章:

java - 如何获取 Maven 依赖项列表以及从中获取它们的存储库

java - 如何使用正则表达式仅匹配字符串中特定位置的模式?

java - 异常: submitTopology failed: out of sequence response

jsf-2 - 如何将 jsf "navigation-rule"用于直接非 .jsf 页面 ("to-view-id"不是 .jsf)

ajax - JSF 2.0 : cookies are not persisted immediately after AJAX call, 需要 HTTP 请求

jsf - 跳过所需的验证并调用应用程序

java - SWT Mac OSX - 未读消息计数(如 Mac Mail 或 Skype)

java - RESTEasy 中的 CORS 过滤器

java - .execute 无法解析为类型 - AsyncTask (Android)

eclipse - 为什么 SpringSource Tool Suite (STS) 这么慢?我该如何解决它?