Spring MVC 3.0 允许音频文件吗?
我正在使用 Spring MVC 3.0,其中指定以下 mvc:resources
标记以允许静态资源通过:-
<mvc:resources location="/resources/" mapping="/resources/**" />
不知何故,我在使音频文件正常工作时遇到问题。我决定将图像文件放置在同一位置只是为了测试路径并且效果很好。
http://server/context/resources/test/image.jpg -> works fine
http://server/context/resources/test/audio.mp3 -> I get 404 error
我阅读了 Spring MVC 文档,但它没有实际上描述了什么被认为是静态资源,我认为 mp3 文件是静态资源。
如何让我的音频文件与 Spring MVC 3.0 一起使用?谢谢。
编辑
我的 servlet.xml 如下所示:-
<context:component-scan base-package="some.project.controller" />
<mvc:annotation-driven />
<mvc:resources location="/resources/" mapping="/resources/**" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/app/" />
<property name="suffix" value=".jsp" />
</bean>
I'm using Spring MVC 3.0 where I specify the following mvc:resources
tag to allow the static resources through:-
<mvc:resources location="/resources/" mapping="/resources/**" />
Somehow, I'm having problem getting my audio files to work. I decided to place an image file in the same location just to test the path and that works fine.
http://server/context/resources/test/image.jpg -> works fine
http://server/context/resources/test/audio.mp3 -> I get 404 error
I read the Spring MVC documentation and it doesn't actually describe what's considered as static resources, and I would think the mp3 file is a static resource.
How do I get my audio file to work with Spring MVC 3.0? Thanks.
EDIT
My servlet.xml looks like this:-
<context:component-scan base-package="some.project.controller" />
<mvc:annotation-driven />
<mvc:resources location="/resources/" mapping="/resources/**" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/app/" />
<property name="suffix" value=".jsp" />
</bean>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我经常需要为 WAS 上的静态内容定义这个 servlet。 将其添加为 .mp3
尝试使用以下映射
I often need to define this servlet for static content on WAS. Try adding it for .mp3
With the following mappings