【问题标题】:JSF 2.2 components are not rendered using Primefaces running on Spring and Maven [duplicate]JSF 2.2 组件不使用在 Spring 和 Maven 上运行的 Primefaces 呈现 [重复]
【发布时间】:2016-04-18 08:56:49
【问题描述】:

当我通过 IE11 或 Firefox45 访问 http://localhost:8081/installer/index.xhtml 时,我只看到设置向导而没有看到 JSF 组件。 HTTP 状态码是 200。我在 Tomcat 7 上没有任何错误。 它在 JSF 1.2 上运行没有问题。我只是不确定 web.xml 文件。

提前致谢。你能告诉我有什么问题吗?

已编辑 当我将扩展名从 .xhtml 更改为 .faces 时,Tomcat 输出出现了一个有用的异常,谢谢。

【问题讨论】:

    标签: jsf-2.2


    【解决方案1】:

    请检查 web.xml 中的 servlet 映射

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>
    

    现在,当我将运行http://localhost:Port/Path/PageName.jsf 时调用您正在运行的 url,就像这里 servlet 一样,但是当我尝试运行 http://localhost:Port/Path/PageName.xhtml 时,它将不起作用。或者我必须对我们这样http://localhost:Port/faces/Path/PageName.xhtml

    【讨论】:

    • 我正在运行localhost:8081/installer/index.xhtml Faces Servletjavax.faces.webapp.FacesServlet30 Faces Servlet*.faces
    • web.xml 文件中的 servlet 映射怎么样?
    • 我运行了 localhost:8081/installer/index.faces 并得到了 #{msg.WEB_ERROR_SHOW_TRACE} #{msg.WEB_ERROR_LINK_BACK} #{msg.WEB_ERROR_LINK_HOME} #{msg.WEB_TOOLBAR_​​BTN_SETTINGS} #{msg. WEB_TOOLBAR_​​BTN_LOGIN}
    • 先尝试简单的代码,只需在页面中添加一个两个组件并渲染它看看发生了什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-25
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 2016-04-20
    • 2012-07-21
    • 1970-01-01
    相关资源
    最近更新 更多