javax.servlet.ServletException:PWC1232:嵌套请求调度的最大深度超过:20

时间:2011-05-11 13:55:19

标签: hibernate jsp jsf

部署JSF页面时出现此错误。我使用Hibernate。我想用一个Java类创建一个简单的JSP表单。

  

javax.servlet.ServletException:PWC1232:嵌套请求调度的最大深度超过:20

我的faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xi="http://www.w3.org/2001/XInclude"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
 <managed-bean>
  <managed-bean-name>modelTime</managed-bean-name>
  <managed-bean-class>org.projet.ModelTime</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
 </managed-bean>

 <navigation-rule> <display-name> home</display-name>
  <from-view-id> /index.jsp</from-view-id> 
  <navigation-case> <from-outcome>newTimesheet</from-outcome> 
  <to-view-id> /newTimesheet.jsp</to-view-id> 
  </navigation-case> 
  </navigation-rule>
</faces-config>

我的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" id="WebApp_ID" version="2.5">
  <display-name>Time</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>*.jsp</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>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
</web-app>

我的newTimesheet.jsp

<%@ page session="true" isThreadSafe="true" import="org.projet.*,java.net.*, java.io.*, java.util.*,net.sf.hibernate.*,net.sf.hibernate.cfg.*,net.sf.hibernate.expression.*" %>


<html>

    <head>
        <meta http-equiv="Content-Language" content="en-us">
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>NewTimesheet</title>
    </head>






    <body topmargin="0" leftmargin="0" vlink="#0000FF" alink="#0000FF">

        <div align="left">
          <table border="0" cellpadding="0" cellspacing="0" bordercolor="#111111" width="84%" height="228" align="left">
            <tr>
              <td width="13%" height="35" align="left" valign="top">&nbsp;</td>
              <td width="87%" height="35" align="left" valign="bottom">
              <font face="Arial"><b>Create a new &quot;timesheet&quot;</b></font></td>
            </tr>
            <tr>
              <td width="14%" height="192" align="left" valign="top">&nbsp;</td>
              <td width="86%" height="192" align="left" valign="top">
              <form method="POST" action="newTimesheet.jsp">
              <input type="hidden" name="CID" value="1">
                <font face="Courier New"><font size="2"><br>
                <br>
                Category:&nbsp;&nbsp;&nbsp;&nbsp; </font>
                <input type="text" name="formCategoryMsg" size="38"><font size="2"><br>
                Description:&nbsp; </font><input type="text" name="formCategoryDescription" size="38"><br>
        &nbsp;</font></p>
                <p align="left"><font face="Courier New">
                <input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></font></p>
              </form>
              <p>&nbsp;</td>
            </tr>
          </table>
        </div>

    </body>

</html>

<%!

这是如何引起的?如何解决?

1 个答案:

答案 0 :(得分:0)

此条目

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

导致FacesServlet在无限循环中运行,因为JSF将在解析视图时委托给JSP servlet,但是您已映射FacesServlet以侦听与servletcontainer相同的URL模式内置的JSP servlet!

将其替换为更具JSF特定的网址格式,例如*.jsf

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

并将您的JSF请求网址更改为以*.jsf结尾。


无关到具体问题,您的表单没有使用JSF标记和托管bean绑定。所以我想知道JSF配置如何与您相关。您可能希望花时间学习JSF。