簡體   English   中英

JSF 2.0導航系統不使用.jsp擴展名

[英]JSF 2.0 Navigation system Not Working with .jsp extension

我已經將JSF2.0用於自動導航系統。我有一個簡單的登錄頁面,當我點擊登錄按鈕時,相應的Bean類的方法已經調用但是當我改變時它不會導航到home.jsp頁面從.jsp到xhtml的擴展然后它工作。 .jsp擴展名有什么問題。

LoginBean.java

public class LoginBean implements Serializable {
private static final long serialVersionUID = 1L;
private String uname;
private String password;


public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public String getUname() {
    return uname;
}

public void setUname(String uname) {
    this.uname = uname;
}

public String loginProject() {
     System.out.println("hello i am called ");
     System.out.println(uname);
     System.out.println(password);
        return "home";
    }
}

===============
login.xhtml

    <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Colonial Inn</title>
</h:head>
<h:body>
<div align="center">
    <h:form id="loginForm">


        <p:growl id="msg" showDetail="true" life="3000" />
        <p:panel header="Login" style="width: 360px,margin-left:200px;">

            <h:panelGrid id="loginPanel" columns="2">

                <h:outputText value="Username" />

                <p:inputText id="username" value="#{loginBean.uname}"
                    required="true">

                </p:inputText>

                <p:spacer></p:spacer>

                <p:message for="username"></p:message>

                <h:outputText value="Password" />

                <p:password id="password" value="#{loginBean.password}"
                    feedback="false" required="true"></p:password>

                <p:spacer></p:spacer>

                <p:message for="password"></p:message>

                <p:spacer></p:spacer>

                <h:commandButton action="#{loginBean.loginProject}" value="Login"></h:commandButton>

            </h:panelGrid>

        </p:panel>

    </h:form>
    </div>

</h:body>

</html>

===================
在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"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>NewCalonialinn</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>

    </welcome-file-list>
    <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>*.do</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-config.xml</param-value>
    </context-param>


    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

</web-app>

================
針對home.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Insert title here</title>
</head>
<body>
<h1>Welcome to home page </h1>
</body>
</html>

.jsp擴展名有什么問題。

它自JSF 2.0以來已被棄用

只需堅持.xhtml擴展名。

也可以看看:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM