When writing springMVC web.xml configuration will encounter
then both what difference does it make? I now make some explanation:
1. When configured <url-pattern>/</url-pattern>
time, it will be matched to the type of path url, it will not match the pattern for the
.jsp type the url
for example:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
This path can match / login / hello type url, but does not match the type index.jsp url.
2. When the configuration <url-pattern><url-pattern>/*<url-pattern>
time, and it will match all types of url, including the path-type, various suffixes like.
E.g:
<filter>
<filter-name>encodingFilter</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>
<!--强制编码-->
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
This can be filtered in various types of url, we .jsp, .html, / hello url and other types will be treated as a UTF-8 encoded.