From 5b060c3636ff54a716ca0a8d0586197b22d2765e Mon Sep 17 00:00:00 2001 From: "1719411461@qq.com" Date: Tue, 8 May 2018 19:47:04 +0800 Subject: [PATCH] =?UTF-8?q?change:=20=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nutz/boot/starter/jetty/JettyStarter.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/nutzboot-starter/nutzboot-starter-jetty/src/main/java/org/nutz/boot/starter/jetty/JettyStarter.java b/nutzboot-starter/nutzboot-starter-jetty/src/main/java/org/nutz/boot/starter/jetty/JettyStarter.java index d87fd798..66c3efa7 100644 --- a/nutzboot-starter/nutzboot-starter-jetty/src/main/java/org/nutz/boot/starter/jetty/JettyStarter.java +++ b/nutzboot-starter/nutzboot-starter-jetty/src/main/java/org/nutz/boot/starter/jetty/JettyStarter.java @@ -18,6 +18,7 @@ import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.servlet.ErrorPageErrorHandler; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceCollection; @@ -194,14 +195,12 @@ public class JettyStarter extends AbstractServletContainerStarter implements Ser wac.getServletContext().setExtendedListenerTypes(true); wac.getSessionHandler().setMaxInactiveInterval(getSessionTimeout()); - List errorHandlers = appContext.getBeans(ErrorPageErrorHandler.class); - ErrorPageErrorHandler ep; - if(errorHandlers.size() > 0){ - ep = errorHandlers.get(0); - }else{ - ep = new ErrorPageErrorHandler(); + ErrorHandler ep = Lang.first(appContext.getBeans(ErrorHandler.class)); + if(ep == null){ + ErrorPageErrorHandler handler = new ErrorPageErrorHandler(); + handler.setErrorPages(getErrorPages()); + ep = handler; } - ep.setErrorPages(getErrorPages()); wac.setErrorHandler(ep); // 设置一下额外的东西