• 首先需要在SpringMvc的配置文件里面写入这一行:
1
<mvc:resources mapping="/res/**" location="/WEB-INF/res/" />
  • 然后在WEB-INF目录下的web.xml内完成以下的配置:
1
2
3
4
5
6
7
8
9
10
11
12
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springMVC.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

Hints 提示
有些朋友喜欢这样写 <url-pattern>*.do</url-pattern> 这样的话SpringMvc只会处理.do的请求哦…是不能做资源映射的哦…