The difference between/* and/in SPRINGMVC
<?xml version= "1.0" encoding= "UTF-8"?>
<web-app version= "2.5"
Xmlns= "Http://java.sun.com/xml/ns/javaee"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">
<display-name>eShop</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--Configure character filters--
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<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-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
--------------------------------------------------------------------------------------------------------------- ---------------------------------------------
The difference between/and/*:
< Url-pattern >/</url-pattern > does not match to *.jsp, that is: *.jsp does not enter spring's Dispatcherservlet class.
< Url-pattern >/* </url-pattern > matches *.jsp, a Dispatcherservlet class that returns to the spring when the JSP view is returned. The corresponding controller is not found, so the 404 error is reported.
In summary, a little knowledge of URL mapping for Web. XML:
< url-pattern>/</url-pattern> will match a path URL such as/login, and will not match a suffix URL of pattern *.jsp
< url-pattern>/*</url-pattern> matches all URLs: path-type and suffix-type URLs (including/login,*.jsp,*.js and *.html, etc.)
1. First/This is the default path, and the expression: when no matching URLs are found, use this URL to match. 2. In Springmvc, multiple Dispatcherservlet can be configured, such as: Configure multiple Dispatcherservlet with/and/*, first match/* this 3. When the configuration is the same, the Dispathcherservlet is configured to/and/* Difference < a >/: Use/Configure the path, direct access to the JSP, without springdispatcherservlet< two >//: Configure/* path, Cannot access to multi-view JSP when I call url:/user/list on the client and then return to the user.jsp view, when the configuration is/:dispathcherservlet get this request and return the corresponding controller, Then the forward type is forwarded to the user.jsp view by Dispather type, which is the request user.jsp view (/user/user.jsp), at which time Dispather does not intercept/user/ User.jsp, because at this time you configure the default/, the smooth handing over to Modleandview to handle the display. When the configuration is/*:dispathcherservlet to get this request and then return the corresponding controller, and then through the Dispather type through forward forwarding to the user.jsp view, that is, the request user.jsp view (/ user/user.jsp), at this time Dispather has been intercepted/user/user.jsp,dispatcher will take him as a controller to match, no match will be reported 404 error. Conclusion: Try to use this method when configuring the view.
See good things to record, about SPRINGMVC in/and/* differences