HTML(5)JSF 2.2中的友好标记不起作用

时间:2015-02-13 18:06:23

标签: html5 jsf jsf-2.2

我尝试使用 JSF 2.2.6 Tomcat 7.0 JSF navigation rule doesn't work on form submit重现此问题中的相同示例,我还阅读了{{3}并且尊重BalusC的答案提供的所有建议,然后我也咨询了这个问题JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output,因为我只想使用.html个文件(我知道我可以使用.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">
<servlet>
    <servlet-name>facesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
   <welcome-file-list>
      <welcome-file>faces/index.html</welcome-file>
   </welcome-file-list>
   <context-param>
      <param-name>javax.faces.PROJECT_STAGE</param-name>
      <param-value>Development</param-value>
   </context-param>
   <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.html</param-value>
</context-param>
</web-app>

faces-config.xml (不需要导航规则,因为它是动态提供的):

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">

    <navigation-rule>
        <display-name>index.html</display-name>
        <from-view-id>/index.html</from-view-id>
        <navigation-case>
            <from-outcome>welcomePage</from-outcome>
            <to-view-id>/welcome.html</to-view-id>
        </navigation-case>
    </navigation-rule>

</faces-config>

BeanFilm.java

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class BeanFilm implements Serializable {

    private String recherche = new String();

    public String getRecherche() {
        return recherche;
    }

    public void setRecherche(String recherche) {
        this.recherche = recherche;
    }

    public String doRecherche() {
        return "welcomePage";
    }


}

的index.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
<head>
<title>Accueil</title>
</head>
<body jsf:id="body" >
        <h1>Plain HTML5 with JSF</h1>
        <form jsf:id="form">
                <input type="text" jsf:id="recherche" jsf:value="#{beanFilm.recherche}"/>
            <input type="submit" jsf:value="Submit" jsf:id="searchButton" jsf:action="#{beanFilm.doRecherche}"/>
        </form>
    <ui:debug/>
</body>
</html>

welcome.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
<head>
<title>Accueil</title>
</head>
<body>

 <h1>Welcome</h1>        

</body>
</html>

问题

确切的问题是,当我点击提交时,方法BeanFilm#doRecherch()永远不会被调用(使用breakpoint),我无法理解为什么?另一个可能有用的信息是,在HTML代码中,源属性仍然像jsf:id="searchButton"这是否意味着HTML尚未生成?

0 个答案:

没有答案