【问题标题】:JSF error web page not found未找到 JSF 错误网页
【发布时间】:2014-01-14 12:21:28
【问题描述】:

大家好,我是 j2ee 开发的初学者 .. 我开发了一个 jsf 应用程序,在其中创建了一些 jsf 视图,但是当我尝试在我的 tomcat 7 服务器上执行它时,我看到的只是一个“页面 web introuvable “ 信息 这是我的代码:

login.xhtml:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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>
 <link rel="stylesheet" type="text/css" href="../css/styles.css"/>
 <title>Authentification</title> 
 </h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
   <h:outputLabel value="Login:" />
   <h:inputText value="#{loginBean.login}" size="30"/>

   <h:outputLabel value="Mot de passe:" />
   <h:inputSecret id="pwdId" value="#{loginBean.password}" size="30" />

   <h:commandButton value="Valider"  type="submit" action="#{loginBean.authentification}" />
   <h:commandButton type="reset" value="Reset" />

</h:panelGrid>
</h:form>
<h:messages style="COLOR: #ff0000;"/>
</h:body>
</html>

index.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!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>
<% response.sendRedirect("pages/login.jsf"); %>
</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" 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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>GestionBibliotheque</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</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>*.jsf</url-pattern>
  </servlet-mapping>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

【问题讨论】:

  • 请回答!!我真的很绝望:/

标签: jsf-2


【解决方案1】:

JSF 2 不支持 JSP。 使用元标记创建 index.html 并重定向到登录页面:

&lt;meta http-equiv="refresh" content="0; url=./login.jsf" /&gt;

简单示例here

【讨论】:

    猜你喜欢
    • 2012-04-22
    • 1970-01-01
    • 2011-11-28
    • 2012-07-07
    • 1970-01-01
    • 2015-06-22
    • 2012-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多