1

I have a Spring MVC 4.x application which has several static resources defined in the application context XML file as:

<mvc:resources mapping="/css/**" location="classpath:/css/" />
<mvc:resources mapping="/images/**" location="classpath:/images/" />
<mvc:resources mapping="/js/**" location="classpath:/js/" />
<mvc:resources mapping="/static/**" location="classpath:/static/" />
<mvc:resources mapping="/static2/**" location="/static/" />

These files are stored in the "/webapp/static/" directory and in the "/resources/static/" directory (see mappings for static2/ and static/ respectively. There are some files in a "js" and "css" subdirectory which are accessible but the files I added recently are returning 404 errors when I try to access them via a local Tomcat server controlled via Netbeans.

I've tried many changes to my spring configuration and looked at the solutions in:

The farthest I've gotten is to be able to load an html file loaded in the root of the "resources/static/" directory, but am not able to get any files from "resources/static/vendor" to load in the web browser.

Community
  • 1
  • 1
Chic
  • 9,836
  • 4
  • 33
  • 62

1 Answers1

0

Problem:

After nearly two days of searching and redeploying. I realized that the issue was not with my Spring MVC configuration. Rather, when I was deploying the application, Netbeans was not copying over all of the static resources.

Looking at the "target/" directory in my project folder I saw that only some of the resources had been moved. I suspect that these were ones that I had specifically edited within netbeans or that were in the project when I last did a clean build.

Solution:

To fix this problem, I simply had to build the project over again before running it. This copied over all of the files in the "webapp/static" directory and in the "resources/static" directory.

Chic
  • 9,836
  • 4
  • 33
  • 62