web.xml配置的dispatcher
<!-- 增加springmvc的分发器 -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:resources/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
SpringMVC框架访问静态资源的方式:并且需要配置在
在web.xml中配置:
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.woff</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.ttf</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.svg</url-pattern>
<servlet-name>default</servlet-name>
<url-pattern>*.swf</url-pattern>
</servlet-mapping>
在dispatcher-servlet.xml中配置:
<!-- <mvc:resources location="/views/**" mapping="/views/**"/> views是Webapp下创建的一个目录-->
<!-- 对静态资源文件的访问 -->
<mvc:default-servlet-handler/>