<!--the project to scan multiple XML files, you must add listeners- <context-param> <param-name>contextconfiglocation</ param-name> <param-value> classpath:spring/ssspring-*. XML, classpath:spring /spring-*. xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class > </listener>
View Code
Add Springmvc
<!--configuration Dispatherservlet--<servlet> <servlet-name>SpringMVC</servlet-name> <s ervlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <!--configuration Springmvc needs to be loaded spring-dao.xml,spring-service.xml,spring-Web. XML Mybatis==>SPRING==>SPRINGMVC-<init-param> <param-name>contextconfiglocation</param- Name> <param-value>classpath:spring/spring-*.xml<!--load multiple XML files at the same time-<!--, Classpath:spring/ssspring-*.xml--</para m-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> < Servlet-mapping> <servlet-name>SpringMVC</servlet-name> <!--intercept all requests by default-<ur L-pattern>/</url-pattern> </servlet-mapping>
View Code
Default access to JSP files
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list >
View Code
Error page Configuration
<error-page> <error-code>401</error-code> <location>/views/error/payerror.jsp </location> </error-page> <error-page> <error-code>403</error-code> <location>/views/common/jsp/error.jsp</location> </error-page> < error-page> <error-code>404</error-code> <location>/views/error/payerror.jsp </location> </error-page> <error-page> <error-code>500</error-code > <location>/views/error/payError.jsp</location>
View Code
The encoding of the request and response is defined through the class Org.springframework.web.filter.CharacterEncodingFilter.
<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>
View Code
Web. XML configuration