【问题标题】:How to add JSF Implementation Libraries? [duplicate]如何添加 JSF 实现库? [复制]
【发布时间】:2016-05-23 04:49:37
【问题描述】:

我正在使用 TomEE。我的印象是 TomEE 已经有了JSF IMplementation Libraries

所以在创建Eclipse项目时,我按照文档选择Library Provided By Target Runtime

上面写着this facet requires jsf implementation library to be present on project classpath. By disabling library configuration, user takes on responsibility of configuring classpath appropriately via alternate means

所以我继续添加 TomEE ...\apache-tomee-webprofile-1.7.4\lib 附带的所有捆绑 jar(这包括 myfaces-api-2.1.17.jarmyfaces-impl-2.1.17.jar


然后我Run on Server下面的测试xhtml但它会呈现一个空白页面。显然,xhtml 没有被编译。所以捆绑的 TomEE jar 没有启动。我怎样才能让那些捆绑的 TomEE jar 编译我的测试 xhtml

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:a="http://xmlns.jcp.org/jsf/passthrough">

    <h:head>
        <title>Hello World - Input Form</title>
    </h:head>
    <h:body>

        <h:form>
            <h:inputText id="name" value="#{theUserName}" 
                            a:placeholder="What's your name?" />

            <h:commandButton value="Submit" action="myresponse" />
        </h:form>

    </h:body>
</html>

【问题讨论】:

  • 你自己说,TomEE已经提供了JSF库,为什么还要选择“用户库”而不是“Target Runtime提供的库”?
  • @BalusC 因为 Eclipse 不会编译 xhtml,除非我下载 JSF
  • 我添加了详细的解释。我知道测试 xhtml 根本没有编译。 JSF 标记未正确解释。这只有在JSF 库没有解释标签时才会发生
  • 您的空白页问题在这里得到解答了吗? stackoverflow.com/q/3112946 如果未找到 JSF 库,您将在 FacesServlet 上获得 ClassNotFoundException,而 webapp 部署将完全阻塞。
  • @BalusC 非常感谢。正如你所说,答案就在那里change the &lt;url-pattern&gt; from /faces/* to *.xhtml

标签: eclipse jsf apache-tomee


【解决方案1】:

TomEE 在tomee/lib 文件夹中有MyFaces 作为JSF 实现。更糟糕的情况是在此处添加它引用 myfaces-api,但确保在打包期间不要将其放入战争中。

【讨论】:

  • 谢谢。我试着完全按照你的建议去做。我提供了更多细节。
猜你喜欢
  • 2011-04-11
  • 2016-10-26
  • 2013-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-27
  • 2019-06-20
  • 2014-05-02
相关资源
最近更新 更多