开发者

File storage in Spring

I would like to save files uploaded from a form to certain folder in my Spring 3 application. I'm a rookie with this, don't know how to 开发者_如何学编程get started. Files must be java File format.


Here's how you can define the absolute path to a temporary directory using System Properties and Spring Expression Language:

<!-- package shortened for readability -->
<bean id="multipartResolver"
      class="org.springframework....CommonsMultipartResolver">
    <property name="uploadTempDir"
      value="#{ systemProperties['java.io.tmpdir'] }/yourwebapp/upload"/>
</bean>

Reference:

  • System Properties and Spring Expression Language
  • System.getProperties() (includes reference for java.io.tmpdir)


Use Spring's FileUpload support, it's fully documented, with examples.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜