Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What makes sense for a library such as Spring MVC, which needs to be open enough to fit all sorts of different use cases, does not necessarily make sense for you to follow when writing a specific application. This is one of those cases.</p> <p>If you are referring to classes such as the <code>Controller</code> interface which as a method signature such as </p> <pre><code>handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception </code></pre> <p>This is likely because, from the perspective of the Spring classes which call into your Controller (such as <code>DispatcherServlet</code>), they don't care what type of Exception your code calls - library code such as <code>DispatcherServlet</code> only needs to know that this class may throw an Exception and therefore is capable of handling Exception in the general case.</p> <p>In other words, <code>DispatcherServlet</code> doesn't need to know what specific type(s) of Exception your Controller may throw - it's going to treat any of them as an "error". This is why the method signature is <code>throws Exception</code>.</p> <p>Now, the API authors could have made the signature use a custom exception type as <code>SpringMvcException</code>, but that would only have the effect of forcing you to handle any checked exception types in your <code>handleRequest</code> method and simply wrap them, which is tedious make-work boilerplate code. So, since pretty much everything with Spring is designed to make it as easy and lightweight for you to integrate with as possible, it's easier for them to specify that the interface method merely <code>throws Exception</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload