Spring Boot Custom Error Page Stack Trace

China☆狼群 提交于 2021-01-27 09:06:20

问题


I have found on several locations how to use Spring boot to make a custom error page but I cannot seem to figure out how to make it show a stack trace.

This is what I have:

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {

    return new EmbeddedServletContainerCustomizer() {
        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {

            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/WEB-INF/jsp/app/404.jsp");
            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/WEB-INF/jsp/app/500.jsp");

            container.addErrorPages(error404Page, error500Page);
        }
    };
}

Any ideas how I could figure this out or how to get the stack trace to begin with?


回答1:


You can't right now using what Spring Boot offers out-of-the-box. There is a pull request that I'd like to merge in 1.3 which should give you enough context to figure out the missing bits.



来源:https://stackoverflow.com/questions/32211434/spring-boot-custom-error-page-stack-trace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!