eclipse javax.servlet.ServletException:PWC1232:超过嵌套请求调度的最大深度:20
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1992391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
提问by Rafal
I have created simple Java Dynamic Web project in Eclipse. I host my project on Glassfish 2.1.1. When I try open p1.jsf
page in browser I got following error:
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
.
我在 Eclipse 中创建了简单的 Java 动态 Web 项目。我在 Glassfish 2.1.1 上托管我的项目。当我尝试p1.jsf
在浏览器中打开页面时,出现以下错误:
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
.
I have no idea how to correct this error...
我不知道如何纠正这个错误......
Here is may p1.jsf
definition:
这是可能的p1.jsf
定义:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!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>
<f:view>
<h:outputLabel value="outputLabel"></h:outputLabel>
</f:view>
</body>
</html>
My web.xml:
我的 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>web4</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>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
My faces-config.xml:
我的faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
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"
version="1.2">
</faces-config>
Error details from Glassfish log:
Glassfish 日志中的错误详细信息:
PWC1406: Servlet.service() for servlet FacesServlet threw exception javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:860)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
回答by BalusC
- FacesServlet should be mapped on an
url-pattern
of*.jsf
(or anything else other than*.jsp
). - No
javax.faces.DEFAULT_SUFFIX
is needed in web.xml if you already use JSP. The JSP page itself must actually be namedpagename.jsp
(and thus notpagename.jsf
, this is the root cause of the recursive forward calls). - Open the page in the webbrowser using the
*.jsf
suffix:http://example.com/context/pagename.jsf
(and thus notbypagename.jsp
, else you would getRuntimeException: FacesContext not found
).
- FacesServlet 应该映射到
url-pattern
of*.jsf
(或除 之外的任何其他东西*.jsp
)。 - 没有
javax.faces.DEFAULT_SUFFIX
需要在web.xml中,如果你已经使用JSP。JSP 页面本身实际上必须被命名pagename.jsp
(因此不是pagename.jsf
,这是递归前向调用的根本原因)。 - 使用
*.jsf
后缀在网络浏览器中打开页面:(http://example.com/context/pagename.jsf
因此不是bypagename.jsp
,否则你会得到RuntimeException: FacesContext not found
)。
回答by Bozho
This means that recursive internal forwards occur. A few things to observe:
这意味着递归内部转发发生。需要注意的几点:
- make sure you are accessing the page via the right suffix. i.e.
http://localhost:8080/app/p1.jsp
, and notp1.page
- you have mapped the jsf suffix to be.jsp
- check your navigation rules in your faces-config.xml
make sure you have the following context-param defined:
<context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.jsp</param-value> </context-param>
- 确保您通过正确的后缀访问该页面。即
http://localhost:8080/app/p1.jsp
,而不是p1.page
- 您已将 jsf 后缀映射为.jsp
- 检查你的 faces-config.xml 中的导航规则
确保您定义了以下上下文参数:
<context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.jsp</param-value> </context-param>
To summarize - the javax.faces.DEFAULT_SUFFIX
determines the file extension under which the page are sought, and the <url-pattern>
of the faces-servlet determines the way the jsf pages are accessed by clients (browsers)
总而言之 -javax.faces.DEFAULT_SUFFIX
确定了寻找页面的文件扩展名,<url-pattern>
faces-servlet 确定了客户端(浏览器)访问 jsf 页面的方式