开发者

File storage in Spring

开发者 https://www.devze.com 2023-01-27 23:44 出处:网络
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.H

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

精彩评论

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