开发者

Spring servlet for serving static content?

开发者 https://www.devze.com 2023-01-06 10:30 出处:网络
I\'m wondering what\'s the Spring way of serving static files. It should support: Written in a Springy way!

I'm wondering what's the Spring way of serving static files. It should support:

  • Written in a Springy way!
  • Simple and reliable
  • Support for resuming downloads (eg. Range request header, and Accept-Ranges, ETag and Last-Modified response headers).
  • Support for client-side caching (eg. If-None-Match and If-Modified-Since request headers, and HEAD requests for ETag, Last-Modified, and Expires response headers
  • Support for GZIP compression (eg. Accept-Encoding: gzip header)

Something like the follo开发者_开发百科wing, but using the idioms of Spring 3...

  • BalusC FileServlet supporting resume and caching and GZIP
  • Servlet for serving static content (question on SO)


You can make a @Controller with @RequestMapping("/static/{resourceName} and use the same logic as in BalusC's Servlet

As for gzip - use Tomcat's or Apache's configuration options.

0

精彩评论

暂无评论...
验证码 换一张
取 消