My jsp loads some additional file like css and js files like almost every website does with something like this:
<script src="js/dhtmlx/dhtmlx.js"></script>
The problem now is, that Spring wants to dispatch the request and isn't finding a proper handler for it, which is right. I tried the following in my config-class:
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/js/**").addResourceLocations("/js/");
}
which is not working, spring still wants to dispatch the request:
org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [...URI/js/dhtmlx/dhtmlx.css] in DispatcherServlet with name 'keza'
How can I tell spring that this is not a request which the framework should dispatch with the dispatcherServlet?
1.Using mvc resources
This enables serving any static content whose location can be specified as a Spring Resource
2. Using mvc:default-servlet-handler:
This provides a way to serve out the static content from the root of the web application even though the Dispatcher Servlet is registered at /, the details of how Spring does this is available at the Spring documentation site here - in brief the responsibility is delegated to the containers default servlet.
MVC resources using spring annotations
make sure your js folder is available under src\main\webapp\resources