Announcement Announcement Module
No announcement yet.
Best way to implement a File Servlet in Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best way to implement a File Servlet in Spring

    Am wondering if there's any Spring trick I could use to implement a FileServlet in Spring?

    I.e. something that will allow to serve files identified by their relative path to a preconfigured directory on disk.

    I already have some very simple code working with normal servlets in a different application, just wondering if there's any class in Spring that would make the thing more Spring like. I went quikcly throught the whole Spring web API without finding anything.

    What do you guys use?

  • #2
    I wrote a very simple implementation as a Spring Controller that simply used Spring to configure that paths that files were stored at, as well as a few other settings. This came in handy as I was testing on a Windows desktop, but deploying to a Linux server, so the paths were different.


    • #3
      Check out the jakarta commons io package, filenameutils and the like.