Eclipse + JSF + Facelets + 组合组件 = 找不到Facelet标签库

4

我将尝试在我的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浏览器中显示运行时警告(在web.xml文件中javax.faces.PROJECT_STAGE = Development):
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缺失消息:CANNOT_FIND_FACELET_TAGLIB

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

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

有没有什么想法,我做错了什么?是我不正确地包含了组合组件,还是我使用了错误的目录来存储我的资源?这是一个 Eclipse/配置问题吗?
【编辑】
针对 Daniel 的评论:
源目录结构:
- project/src/main/
- java/ - webapp/
部署目录结构:
- project
- HTML 文件 - resources/(包括 emcomp/ 文件夹) - META-INF/ - WEB-INF/(配置文件和 lib/ 文件夹)

你确定路径不应该是:webapp/resources/ 而不是 src/main/webapp/resources/ 吗? - Daniel
@Daniel,我正在使用默认的Maven目录结构。请参见编辑后的问题以获取更多详细信息。 - Alex Averbuch
只是好奇,将<body>替换为<h:body>,这种东西可能会破坏JSF... - Daniel
谢谢你的提示,但是它没有帮助。 - Alex Averbuch
1个回答

4

从 XML 命名空间 URI 中删除尾部斜杠。

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

2
我有同样的问题,但没有尾随斜杠 :( - Mark W

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接