javax.servlet.ServletException:PWC1232:超出嵌套请求分派的最大深度:20
当我部署 JSF 页面时,出现此错误。我使用休眠。我想用一个 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"> </td>
<td width="87%" height="35" align="left" valign="bottom">
<font face="Arial"><b>Create a new "timesheet"</b></font></td>
</tr>
<tr>
<td width="14%" height="192" align="left" valign="top"> </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: </font>
<input type="text" name="formCategoryMsg" size="38"><font size="2"><br>
Description: </font><input type="text" name="formCategoryDescription" size="38"><br>
</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> </td>
</tr>
</table>
</div>
</body>
</html>
<%!
这是怎么造成的以及如何解决?
I get this error when I deploy my JSF page. I use Hibernate. I want to create a simple JSP form with one Java class.
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
My 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>
My 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>
My 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"> </td>
<td width="87%" height="35" align="left" valign="bottom">
<font face="Arial"><b>Create a new "timesheet"</b></font></td>
</tr>
<tr>
<td width="14%" height="192" align="left" valign="top"> </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: </font>
<input type="text" name="formCategoryMsg" size="38"><font size="2"><br>
Description: </font><input type="text" name="formCategoryDescription" size="38"><br>
</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> </td>
</tr>
</table>
</div>
</body>
</html>
<%!
How is this caused and how can I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此条目
导致
FacesServlet
在无限循环中运行,因为 JSF 在解析视图时将委托给 JSP servlet,但您已将FacesServlet
映射为侦听同一视图URL 模式作为 servletcontainer 的内置 JSP servlet!将其替换为更特定于 JSF 的 URL 模式(例如
*.jsf
),并将 JSF 请求 URL 更改为以
*.jsf
结尾。与具体问题无关,您的表单没有使用 JSF 标记和托管 bean 绑定。所以我想知道 JSF 配置与您有何关系。您可能想首先花时间学习 JSF。
This entry
is causing the
FacesServlet
to run in an infinite loop because JSF will delegate to the JSP servlet when resolving views, but you've mapped theFacesServlet
to listen on the same URL pattern as the servletcontainer's builtin JSP servlet!Replace it by a more JSF-specific URL pattern such as
*.jsf
and change your JSF request URLs to end with
*.jsf
instead.Unrelated to the concrete problem, your form is not utilizing JSF tags and managed bean bindings. So I wonder how the JSF configuration is relevant to you. You might want to spend time in learning JSF first.