Ok so I have encountered the fairly common errror:
WARNING: No mapping found for HTTP request with URI [/WEB-INF/jsp/index.jsp] in DispatcherServlet with name
Essentially what is happening is, since you have Spring's DispatcherServlet mapped to /*
, it tends to be called for every request(which is okay), but unfortunately gets invoked even when the request gets dispatched to the JSP page (/WEB-INF/jsp/index.jsp
), instead of the containers default servlet getting invoked.
The fix that I am aware of is the following:
Map it to the default servlet path /
instead:
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
One issue that you would see with above is that the resources under the root of your webapp will unfortunately get handled by DispatcherServlet which will not know what do with it, the fix is to register a default-servlet-handler this way:
<mvc:default-servlet-handler />
I will try to explain the "flow" of a request in a Spring Web MVC application.
When sending a request to your application the following happens:
preHandle
methodspostHandle
method (e.g. for modifying the model)ViewResolver
. Depending on the ViewResolver the result can be jsp page, a tiles view, a thymeleaf template or many other 'Views'. In your case the ViewResolver
resolves a view name (e.g. 'myPage') to a jsp file (e.g. /WEB-INF/jsp/myPage.jsp
)afterCompletion
method)Feel free to correct me if I'am not 100% correct or if I missed something :-)