How should you handle exceptions that occur below the level of the Controller in a Spring MVC web app?

It very much depends on the concrete case: you can show the exception message (translated by some exception translation mechanism to a human-readable representation) together with validation message - for example "Email sending failed, please try again later" If the exception can't be recovered from, you can redirect to a page which will display human-readable explanation you can redirect to a generic 500 page that says "Oops, something went wrong" Pick one option that you feel best fits your use-case in terms of usability.

I think logging and handling system exceptions should be done by the service layer. If you think about it in service-oriented terms, there may not be a UI calling a particular service. All system level cleanup needs to happen in that layer.

With that said, no exception should ever escape the controller layer. There needs to be enough communication between the service and controller layers so the controller can tell the user what's going on in friendly, easy-to-understand terms. Communicating back to users is the controller's duty.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions