1

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>
limc
  • 39,366
  • 20
  • 100
  • 145

1 Answers1

3

I often need to define this servlet for static content on WAS. Try adding it for .mp3

<servlet>
    <servlet-name>static</servlet-name>
    <servlet-class>com.ibm.ws.webcontainer.servlet.SimpleFileServlet</servlet-class>
</servlet>

With the following mappings

<servlet-mapping>
    <servlet-name>static</servlet-name>
    <url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>static</servlet-name>
    <url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>static</servlet-name>
    <url-pattern>*.mp3</url-pattern>
</servlet-mapping>
Eric Winter
  • 960
  • 1
  • 8
  • 17