简体   繁体   中英

Spring JavaConfig: error handling with WebApplicationInitializer

I'm trying to handle errors such as Not Found (404), Acces Denied (403), Bad Request (400) etc. in Spring MVC web app.

I use WebApplicationInitializer instead of web.xml to initialize my web app. It would be simple to configure http errors handling in web.xml:

<error-page>
    <error-code>404</error-code>
    <location>/error/404</location>
</error-page>

I found how to handle Acces Denied error only: How do I add an Access Denied Handler in spring-security-javaconfig

But is there any clear solution to handle http errors in web application initialized by WebApplicationInitializer?

Unfortunately there is no error-page equivalent in java config servlet initialization. You have to override it on application server level

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM