Spring MVC 文件上传和公共目录 [英] Spring MVC file upload and public directory
问题描述
我有一个类似downloads"的文件夹(完整路径:C:\tomcat\downloads"
).
I have a folder like "downloads" (full path: "C:\tomcat\downloads"
).
这是我抛出所有上传文件的文件夹.现在我想像这样访问它们:
This is the folder where I throw all the uploaded files. Now I want to access them like this one:
在这个文件夹下载"中,可以是任何东西.
In this folder "downloads", can be anything.
唯一的问题是应该怎么做才能制作公用文件夹.目前我可以将发送的文件保存到磁盘并删除它们.但是,我想像上面一样访问它们.
The only question is what should be done to make public folder. At the moment I can save the sent files to disk and delete them. However, I want to access them like above.
这取决于spring或tomcat服务器的配置?一些例子...
It depends on the configuration of spring or tomcat server? Some examples...
推荐答案
或者你可以使用
喜欢
<mvc:resources mapping="/images/**" location="file:/absolute/path/to/image/dir"/>
这可以更容易、更快捷.欲了解更多信息,请查看此处http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/resources.html
This can be more easier and faster. For further information, check here http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/resources.html
这篇关于Spring MVC 文件上传和公共目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!