我正在尝试将复合组件添加到我的 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 版本的 m2e
和 m2e-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/