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.
精彩评论