Custom Error Page in Tomcat 7 for Error Code 500

前端 未结 2 409
温柔的废话
温柔的废话 2020-12-16 13:30

Guys I am struggling with the problem of opening my custom error page in Tomcat in Windows Environment. Some of solution I got but no luck. I tried almost all links but its

2条回答
  •  眼角桃花
    2020-12-16 14:04

    The same can be implemented programmatically if you use embedded Tomcat for example like this:

            Context appContext = ...            
            ErrorPage errorPage = new ErrorPage();
            errorPage.setErrorCode(HttpServletResponse.SC_NOT_FOUND);
            errorPage.setLocation("/my_custom_error_page.html");
            appContext.addErrorPage(er);
    

提交回复
热议问题