繁体   English   中英

JSF表单未显示

[英]JSF form not shown

我想使用jsf实现一个登录页面,我想实现一个表单:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Login</title>
    <link href="../resources/css/basic.css" type="text/css" rel="stylesheet" />
</h:head>
<h:body>
<div id="wrapper">
    <ul id="menu">
        <li id="menutab"><a class="link" href="../index.jsp">Home</a></li>
        <li id="menutab"><a class="link" href="../jsf/list.jspx">Liste</a></li>
        <li id="menutab"><a class="link" href="../servlets/DataServlet">Daten</a></li>
        <li id="menutab"><a class="link" href="../servlets/ListMoviesServlet">Movies</a></li>
        <li id="menutab"><a class="link" href="../servlets/ListPeopleServlet">People</a></li>
    </ul>
    <br></br>
    <h2 id="title">Login</h2>

    <h:form id="j_security_check">
        <center>
            <h:messages errorClass="errorMessage" infoClass="infoMessage" warnClass="warnMessage"></h:messages>
            <h:panelGrid columns="2">
                <h:outputText value="Username : "/>
                <h:inputText id="j_username" value="#{loginBean.username}"/>

                <h:outputText value="Password : "/>
                <h:inputSecret id="j_password" value="#{loginBean.password}"/>

                <h:commandButton value="Submit" action="#{loginBean.login}" type="submit"/>
            </h:panelGrid>
        </center>
    </h:form>
</div>
</h:body>
</html>

显示了页面,但未显示此处定义的形式。 标题之后的所有内容都只是白屏。 为什么不呈现表单?

好,我知道了!

这是我的web.xml中的jsf映射:

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

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>

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

如您所见,URL模式描述了“ .jspx”

所以我必须用“ myjsf.jspx”而不是“ myjsf.xhtml”来调用我的jsf

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>loginRealm</realm-name>
    <form-login-config>
        <form-login-page>/jsf/login.jspx</form-login-page>
        <form-error-page>/jsf/error.jspx</form-error-page>
    </form-login-config>
</login-config>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM