Set throwExceptionIfNoHandlerFound=true and deprecate

Closes gh-29491
This commit is contained in:
rstoyanchev
2023-06-19 17:17:38 +01:00
parent c00508d6cf
commit 089d938e15
7 changed files with 23 additions and 12 deletions

View File

@@ -305,7 +305,7 @@ public class DispatcherServlet extends FrameworkServlet {
private boolean detectAllViewResolvers = true;
/** Throw a NoHandlerFoundException if no Handler was found to process this request? *.*/
private boolean throwExceptionIfNoHandlerFound = false;
private boolean throwExceptionIfNoHandlerFound = true;
/** Perform cleanup of request attributes after include request?. */
private boolean cleanupAfterInclude = true;
@@ -467,7 +467,12 @@ public class DispatcherServlet extends FrameworkServlet {
* <p>Default is "false", meaning the DispatcherServlet sends a NOT_FOUND error through the
* Servlet response.
* @since 4.0
* @deprecated as of 6.1 this property is set to {@code true} by default, and
* should not need to be customized; in effect, {@link DispatcherServlet}
* should always raise {@link NoHandlerFoundException} and allow it to be
* handled through a {@link HandlerExceptionResolver}.
*/
@Deprecated(since = "6.1", forRemoval = true)
public void setThrowExceptionIfNoHandlerFound(boolean throwExceptionIfNoHandlerFound) {
this.throwExceptionIfNoHandlerFound = throwExceptionIfNoHandlerFound;
}