解决方法1:在web.xml里添加如下的配置
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping> <servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern> </servlet-mapping> <servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping> <servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
解决方法2:在spring的配置文件中添加如下一行:
<mvc:default-servlet-handler/>
注意,需要是spring3.0.5以上版本
解决方法3:这个配置告诉spring 静态资源的处理方式
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<mvc:resources mapping="/resources/**" location="/resources/" />