JSF 导航规则不适用于表单提交

JSF navigation rule doesn't work on form submit

我正在尝试使用 JSF 制作几个非常简单的 HTML 页面,以在数据库中搜索某些内容,但出于某种原因,当我点击提交按钮时,没有任何反应。文本输入变为空,没有其他任何事情发生。它应该转到显示结果的另一个页面。

这是我的文件:

index.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
<head>
<meta charset="ISO-8859-1">
<title>Accueil</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="card">
        <h1>Cinésthésie</h1>
        <form jsf:id="Form_Recherche">
            <div class="inputWrapper">
                <input type="text" id="recherche" jsf:value="beanFilm.recherche" required><label>Que recherchez-vous ?</label>
            </div>
            <input type="submit" value="" id="searchButton" jsf:action="#{beanFilm.doRecherche}"/>
        </form>
    </div>
</body>
</html>

脸-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">
    <managed-bean>
        <managed-bean-name>beanFilm</managed-bean-name>
        <managed-bean-class>bean.BeanFilm</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <display-name>index.html</display-name>
        <from-view-id>/index.html</from-view-id>
        <navigation-case>
            <from-outcome>toResultatsRecherche</from-outcome>
            <to-view-id>/resultatsRecherche.html</to-view-id>
        </navigation-case>
    </navigation-rule>

</faces-config>

BeanFilm.java

public class BeanFilm implements Serializable {

    private static final long serialVersionUID = 1L;

    private String recherche = new String();

    public String getRecherche() {
        return recherche;
    }

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

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

    public List<Film> getResultatsRecherche() {
        return DAOFilmJPA.getInstance().getFilmsByTitle(recherche);
    }

}

我已经尝试了几个小时了,我想我一定错过了一个重要的点。 有什么想法吗?

我找到方法了。

我似乎没有渲染 jsf 标签,所以我将每个 html 文件切换到 xhtml 并在 web.xml 中更改了这个

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

至此

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

它解决了问题,但现在我需要遵守 xhtml 严格的语法,同时我尝试使用 HTML5。有什么建议吗?