1

I have a Spring MVC project i have some resources like images and pictures that is being called by the application. I am getting a 404 Not Found Error when i request the resources. E.g. I have a swf file his should be loaded with a page but it keeps giving the 404 message in firebug.

I have this file located outside the WEB-INF directory in a directory called swf. This was working previously and for some reason it stopped. Can someone assist me with the configuration details and location of where resources called by the application should be located. I am aware that files that the Spring container requests can be located inside the WEB-INF directory and all others must reside outside (i stand to be corrected on this).

File Structure:

-app
 -src
 -test
 -db
 -war
  -images
  -swf
  -WEB-INF
   -classes
   -css
   -js
   -jsp
   -lib
   -photos
   -tld
4

1 に答える 1

2

There's something really wrong with your file structure. You have JS and CSS under WEB-INF folder. These files will not be accessible from web. Static contents cannot be placed under WEB-INF folder.

Structure your files, like this:-

-app
    -src
    -test
    -db
    -war
        - resources
            -images
            -css
            -js
            -swf
    -WEB-INF
        -classes
        -jsp
        -lib

Add this line to your spring-servlet.xml:-

<mvc:resources location="/resources/" mapping="/resources/**" />

With this, your base URL for all static contents become /<context-root>/resources/, ex: /myapp/resources/images/test.jpg.

Further, it is possible that your application server isn't configured to serve SWF file. So, if the image files work fine but the SWF files don't work, you may want to add the following mime type to your web.xml:-

<mime-mapping>
    <extension>swf</extension>
    <mime-type>application/x-shockwave-flash</mime-type>
</mime-mapping> 

EDIT

The solution to this problem is to write a small servlet to serve SWF file.

于 2013-01-14T01:19:35.507 に答える