Web. XML configuration

Source: Internet
Author: User

<!--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==&GT;SPRING==&GT;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.