Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Spring not throwing NoHandlerFoundException anymore #9263
After we upgraded from Spring Boot 1.4.0 to 1.5.3 our web application does not throw the NoHandlerFoundException anymore. Configuration looks like the following:
the corresponding exception controller:
We had no problems with Spring 1.4.0 but it stopped working in 1.5.3. Why is the exception not thrown anymore?
While preparing a sample application we've found the culprit:
Replacing the URl pattern with the subfolder containing the static resources
By default, the DispatcherServlet does not throw a NoHandlerFoundException. You need to enable that:
I use Spring Boot 1.5.4.RELEASE:
and in my prop file I added
Sorry to re-open this issue, but I am experiencing a very closely related problem.
I am not using
Is there a way to accomplish this?
My issue is basically the same as this StackOverflow page: https://stackoverflow.com/questions/39973945/no-handler-found-exception-and-static-recources-in-spring-boot
@AndRossi the answer on that SO thread is right.
When the resource handler doesn't find a static resource to serve, it's not delegating to the next handler in line, but rather responding with an HTTP 404. The only way to achieve what you want is to map your static resources under a specific sub-path like
Hi @bclozel, thank you for the lightning-fast answer!
Unfortunately I have tried that answer but it does not seem to work in my scenario.
In my environment, it does allow the client to get the static resources, but missing URIs do not throw any exceptions :/