我已经存储在一个文件夹(例如C:\ test \ tes.png)中的媒体(图片和电影),我试图访问与像这样的网址的图片:http://localhost:8080/app/picture/test.png 。 要做到这一点,我已经使用的资源标签(弹簧3)如下:春天mvc:资源访问外部文件夹
<mvc:resources mapping="/picture/**" location="file:/test" />
当我尝试访问,我有没有更多的细节错误。
请求资源未找到
我在日志:
2011-11-07 20:48:55241 [HTTP-8080-2] DEBUG org.springframework.web .servlet.DispatcherServlet - 名为'Family'的DispatcherServlet处理[/Family/photos/testImage2.png]的GET请求 2011-11-07 20:48:55,241 [http-8080-2] DEBUG org.springframework.web。 servlet.handler.SimpleUrlHandlerMapping - 请求[/photos/testImage2.png]的匹配模式是[/ **] 2011-11-07 20:48:55,241 [http-8080-2] DEBUG org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - 请求的URI模板变量[/photos/testImage2.png]为{} 2011- 11-07 20:48:55,242 [http-8080-2] DEBUG org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - 使用handler [org.springframework.web.servlet。将映射[/photos/testImage2.png]映射到HandlerExecutionChain。 [email protected]]和4个拦截器 2011-11-07 20:48:55,242 [http-8080-2] DEBUG org.springframework.web.servlet.DispatcherServlet - [/ Family/photos/testImage2的Last-Modified值.png]:-1 2011-11-07 20:48:55,242 [http-8080-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Null ModelAndView返回名为'Family'的DispatcherServlet:假设HandlerAdapter已完成请求处理 2011-11-07 20:48:55 ,242 [HTTP-8080-2] DEBUG org.springframework.web.servlet.DispatcherServlet - 成功完成请求
我肯定不是全部明白...
另一个问题是:我不知道这是一个好方法。访问外部文件夹上媒体的其他解决方案是什么?
在此先感谢!
你可以在你的webapp中拥有一个媒体文件夹的快捷方式吗? –
查看Spring Resources servlet。它可以提供你想要的功能。 – DwB