Java 类org.eclipse.jetty.servlet.ErrorPageErrorHandler 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JettyEmbeddedServletContainerFactory.java   
private void addJettyErrorPages(ErrorHandler errorHandler,
        Collection<ErrorPage> errorPages) {
    if (errorHandler instanceof ErrorPageErrorHandler) {
        ErrorPageErrorHandler handler = (ErrorPageErrorHandler) errorHandler;
        for (ErrorPage errorPage : errorPages) {
            if (errorPage.isGlobal()) {
                handler.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE,
                        errorPage.getPath());
            }
            else {
                if (errorPage.getExceptionName() != null) {
                    handler.addErrorPage(errorPage.getExceptionName(),
                            errorPage.getPath());
                }
                else {
                    handler.addErrorPage(errorPage.getStatusCode(),
                            errorPage.getPath());
                }
            }
        }
    }
}
项目:spring-boot-concourse    文件:JettyEmbeddedServletContainerFactory.java   
private void addJettyErrorPages(ErrorHandler errorHandler,
        Collection<ErrorPage> errorPages) {
    if (errorHandler instanceof ErrorPageErrorHandler) {
        ErrorPageErrorHandler handler = (ErrorPageErrorHandler) errorHandler;
        for (ErrorPage errorPage : errorPages) {
            if (errorPage.isGlobal()) {
                handler.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE,
                        errorPage.getPath());
            }
            else {
                if (errorPage.getExceptionName() != null) {
                    handler.addErrorPage(errorPage.getExceptionName(),
                            errorPage.getPath());
                }
                else {
                    handler.addErrorPage(errorPage.getStatusCode(),
                            errorPage.getPath());
                }
            }
        }
    }
}
项目:nexus-public    文件:ErrorPageServletTest.java   
@Before
public void setUp() throws Exception {
  TemplateHelper templateHelper = new TemplateHelperImpl(new ApplicationVersionSupport()
  {
    @Override
    public String getEdition() {
      return "Test";
    }
  }, new VelocityEngine());

  ServletContextHandler context = new ServletContextHandler();
  context.addServlet(new ServletHolder(new ErrorPageServlet(templateHelper)), "/error.html");
  context.addServlet(new ServletHolder(new BadServlet()), "/bad/*");

  ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
  errorHandler.addErrorPage(GLOBAL_ERROR_PAGE, "/error.html");
  context.setErrorHandler(errorHandler);

  BaseUrlHolder.set("http://127.0.0.1");

  server = new Server(0);
  server.setHandler(context);
  server.start();

  port = ((ServerConnector) server.getConnectors()[0]).getLocalPort();
}
项目:contestparser    文件:JettyEmbeddedServletContainerFactory.java   
private void addJettyErrorPages(ErrorHandler errorHandler,
        Collection<ErrorPage> errorPages) {
    if (errorHandler instanceof ErrorPageErrorHandler) {
        ErrorPageErrorHandler handler = (ErrorPageErrorHandler) errorHandler;
        for (ErrorPage errorPage : errorPages) {
            if (errorPage.isGlobal()) {
                handler.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE,
                        errorPage.getPath());
            }
            else {
                if (errorPage.getExceptionName() != null) {
                    handler.addErrorPage(errorPage.getExceptionName(),
                            errorPage.getPath());
                }
                else {
                    handler.addErrorPage(errorPage.getStatusCode(),
                            errorPage.getPath());
                }
            }
        }
    }
}
项目:getty    文件:ApplicationInstanceManager.java   
private void setupErrorPages(WebAppContext context, List<ErrorHandler> errorHandlers) {
    if (errorHandlers != null) {
        ErrorPageErrorHandler errorHandler = (ErrorPageErrorHandler)context.getErrorHandler();
        for (ErrorHandler handler : errorHandlers) {
            String page = handler.getFile();
            if (!StringUtils.startsWith(page, "/")) {
                page = "/" + page;
            }

            if (handler.getErrorCode() > 0) {
                errorHandler.addErrorPage(handler.getErrorCode(), page);
            } else {
                errorHandler.addErrorPage(Integer.MIN_VALUE, Integer.MAX_VALUE, page);
            }
        }
    }
}
项目:bootique-jetty    文件:ServerFactory.java   
protected Handler createHandler(Set<MappedServlet> servlets,
                                Set<MappedFilter> filters,
                                Set<MappedListener> listeners) {

    int options = 0;

    if (sessions) {
        options |= ServletContextHandler.SESSIONS;
    }

    ServletContextHandler handler = new ServletContextHandler(options);
    handler.setContextPath(context);
    if (params != null) {
        params.forEach((k, v) -> handler.setInitParameter(k, v));
    }

    if (staticResourceBase != null) {
        handler.setResourceBase(staticResourceBase.getUrl().toExternalForm());
    }

    if (compression) {
        handler.setGzipHandler(createGzipHandler());
    }

    if (errorPages != null) {
        ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
        errorPages.forEach((statusCode, location) -> errorHandler.addErrorPage(statusCode, location));
        handler.setErrorHandler(errorHandler);
    }

    installListeners(handler, listeners);
    installServlets(handler, servlets);
    installFilters(handler, filters);

    return handler;
}
项目:backstopper    文件:Main.java   
private static ErrorHandler generateErrorHandler() {
    ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
    errorHandler.addErrorPage(Throwable.class, "/error");
    return errorHandler;
}