* .do suffix represents the intercept will do the
<url-pattern> *. do </ url-pattern>
/ denote any request must go through DispatcherServlet including images, css need at this time to release static resources springmvc-servlet.xml
Static resources can be properly displayed.
You need springmvc add a configuration file.
springmvc-servlet.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:context="http://www.springframework.org/schema/context" 5 xmlns:mvc="http://www.springframework.org/schema/mvc" 6 xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd 7 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 8 http://www.springframework.org/schema/context/spring-context-4.2.xsd http://www.springframework.org/schema/context " > . 9 < context: Scan-Component Base-Package =" COM. zhiyou100.wc.controllter " /> 10 . 11 <-! open drive annotation -> 12 is < MVC: annotation-driven /> 13 is <-! releasing static resources -> 14 < MVC: the servlet-default-Handler / > 15 16 <! - view resolver -> . 17 < the bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver"> 18 <property name="prefix" value="/WEB-INF/views/"/> 19 <property name="suffix" value=".jsp"/> 20 21 </bean> 22 23 24 25 </beans>
web.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> 3 <display-name>Springmvc-0903</display-name> 4 <welcome-file-list> 5 <welcome-file>index.html</welcome-file> 6 <welcome-file>index.htm</welcome-file> 7 <welcome-file>index.jsp</welcome-file> 8 <welcome-file>default.html</welcome-file> 9 <welcome-file>default.htm</welcome-file> 10 <welcome-file>default.jsp</welcome-file> 11 </welcome-file-list> 12 13 <!-- The front controller of this Spring Web application, responsible for handling all application requests --> 14 <servlet> 15 <servlet-name>springmvc</servlet-name> 16 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 17 <init-param> 18 <param-name>contextConfigLocation</param-name> 19 <!-- --> <20 param-value>classpath:spring/springmvc-*.xml</param-value> 21 </init-param> 22 <load-on-startup>1</load-on-startup> 23 </servlet> 24 25 <!-- Map all requests to the DispatcherServlet for handling --> 26 <servlet-mapping> 27 <servlet-name>springmvc</servlet-name> 28 <!-- *.do表示后缀为do的才会拦截 --> 29 <-! <Url-pattern> * do </ url-pattern>. -> 30 <-! / Denote any request must go through DispatcherServlet including images, css this time need to be released within springmvc-servlet.xml static resources -> 31 is < URL-pattern > / </ URL-pattern > 32 </ the servlet-Mapping > 33 is </ Web-App >