web.xml中的错误页面指令不起作用

时间:2015-05-07 00:09:24

标签: java jsp web.xml custom-error-pages

我正在尝试简单地在发生错误时显示我的默认错误页面。我已经尝试了我能想到的所有配置,但我无法让它发挥作用。当我直接导航到错误页面时,它可以工作,但错误不会指向那里(在本机Eclipse浏览器或任何主流浏览器中)。

DD中没有错误。

以下是我目前如何使用DD:



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>MyApp</display-name>
  <servlet>
    <servlet-name>GetUser</servlet-name>
    <servlet-class>com.example.web.GetUser</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>GetUser</servlet-name>
    <url-pattern>/GetUser.do</url-pattern>
  </servlet-mapping>
  <session-config>
  	<session-timeout>15</session-timeout>
  </session-config>
  <jsp-config>
  	<taglib>
  		<taglib-uri>Functions</taglib-uri>
  		<taglib-location>/WEB-INF/functions.tld</taglib-location>
  	</taglib>
  </jsp-config>
  <error-page>
  	<location>/MyApp/errorPage.jsp</location>
  </error-page>
  <error-page>
  	<error-code>404</error-code>
  	<location>/MyApp/errorPage.jsp</location>
  </error-page>
  <error-page>
  	<error-code>429</error-code>
  	<location>/MyApp/errorPage.jsp</location>
  </error-page>
  <error-page>
  	<exception-type>java.io.IOException</exception-type>
  	<location>/MyApp/errorPage.jsp</location>
  </error-page>
</web-app>
&#13;
&#13;
&#13;

(我指的是429因为我正在使用的API最近向我扔了这些API)

以下是错误页面:

&#13;
&#13;
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" isErrorPage="true" %>
<!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>You blew it</title>
</head>
<body>
<p>You caused a ${pageContext.exception} exception</p>
</body>
</html>
&#13;
&#13;
&#13;

如果它有帮助,这里是429错误,以及我得到的后续IOException错误日志(不是在这里解决这个问题,以防它有帮助)。

&#13;
&#13;
java.io.IOException: Server returned HTTP response code: 429 for URL: https://dpu-ten-web.api-connect.com/api/rest/user
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
	at com.example.web.GetUser.doPost(GetUser.java:93)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
	at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Server returned HTTP response code: 429 for URL: https://dpu-ten-web.api-connect.com/api/rest/user
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
	at com.example.web.GetUser.doPost(GetUser.java:86)
	... 24 more
&#13;
&#13;
&#13;

非常感谢任何帮助。

0 个答案:

没有答案