Using Spring ResourceServlet to Serve Multiple Resources Simultaneously

The JavaDoc for ResourceServlet states that it can return a list of resources. But examples of this usage pattern seem to be rare at best.

We have web.xml with the following:

<servlet> <servlet-name>Resource</servlet-name> <servlet-class>org.springframework.web.servlet.ResourceServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Resource</servlet-name> <url-pattern>/combo</url-pattern> </servlet-mapping> 

When we query the URL line by line: http: // localhost: 8080 / app / combo? Resource = js / file1.js; js / file2.js

It seems we get file1 in the response.

What will be the correct configuration for this use case?

+6
source share
2 answers

The problem in our case was that the application used the mvc: resource utility to manage versions of static files. The mvc: resource utility backend will not respond to multiple files properly, as Bosho noticed, and I also did not know what to look at the source.

+1
source

ResourceServlet deprecated in favor of using <mvc:resources /> However, it does not process multiple resources. You must make your own controller for this.

As for the ResourceServlet , the delimiters used in the code are ,; \t\n ,; \t\n - any of them should work.

+2
source

Source: https://habr.com/ru/post/888440/


All Articles