Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Spring ResourceServlet to serve multiple resources simultaneously

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

We have a 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 make a request to url along the lines of: http://localhost:8080/app/combo?resource=js/file1.js;js/file2.js

We only seem to get file1 in the response.

What would a proper configuration be for this use case?

like image 927
Matt Avatar asked May 18 '11 15:05

Matt


1 Answers

The ResourceServlet has been deprecated in favour of using <mvc:resources /> However, it doesn't handle multiple resources. You'd have to make your own controller to do that.

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

like image 72
Bozho Avatar answered Nov 15 '22 00:11

Bozho