【问题标题】:JSF2.2 tags working with *.xhtml but not working with *.htmlJSF2.2 标记可与 *.xhtml 一起使用,但不能与 *.html 一起使用
【发布时间】:2014-04-05 17:42:04
【问题描述】:

我无法在 (*.html) 中使用 jsf 标签,但如果我将页面更改为 *.xhtml,它就可以工作了。

帮助我理解为什么会这样。

以下是web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <display-name>Project</display-name>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    <servlet>
        <description></description>
        <display-name>FacesServlet</display-name>
        <servlet-name>FacesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
</web-app>`

【问题讨论】:

  • JSF 正在生成 HTML,它不需要 html 文件作为输入。暗中刺探:你没有告诉你的 Faces Servlet 你想让它渲染html 文件吗?你能告诉我们你的web.xml吗?
  • 如果我为 *.html 提供映射并且如果我尝试运行 *.html 我会找不到页面

标签: html xhtml jsf-2.2


【解决方案1】:

将其包含在您的 web.xml 中

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.html</param-value>
</context-param>

【讨论】:

  • 我可以运行 html 页面,但标签仍然不起作用...建议其他任何...提前谢谢
猜你喜欢
  • 2014-03-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-14
  • 2012-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多