Java – not all exceptions are mapped to resolveexception in simplemappingexceptionresolver

I override resolveexception in simplemappingexceptionresolver to send an e-mail containing stacktrace. The e-mail applies to 500 errors, but 400 errors do not reach this method (there is no stack trace to send, but I still want to send an email and display a good error page.)

Is there any way to do this, or should I configure my web XML to process 400 (and similar)?

Solution

I think you will find this answer very helpful:

Spring SimpleMappingExceptionResolver not going to default view

TL; Dr spring exceptionresolvers does not handle all exceptions, only the exceptions thrown by the controller When spring cannot convert the submitted data of the mapping controller, it may throw a "400 - error request", and the exception you throw will never be seen by your exceptionhandler

Your web The XML solution should work well

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>