Spring MVC +mybatis + Maven configuration web.xml configuration __spinrg

Source: Internet
Author: User
Tags define session tld log4j
web.xml role, and web container execution orderEach site typically has a web.xml that is used to initialize configuration information, but is not required. Web.xml is the first file that the Web container reads. The order in which the Web container executes is:
1. When starting a Web project, the Web container reads its profile web.xml, reads <listener> and <context-param> two nodes.
2. The container creates a ServletContext (servlet context) in which all parts of the Web project will share this context.
3. The container will convert <context-param> to the key value pair and give it to ServletContext.

4, the container creates the class instance in the <listener>, creates the listener.

Web.xml Configure execution sequence servletcontext-> Context-param->listener-> filter-> servlet web.xml The contents of the items configured in the log4j configuration file load definition application initialization definition Spring MVC configuration definition Prevent spring memory overflow configuration
Define the requested character set filter define the default page definition for the entire application access JSTL Custom function file configuration definition Verification Code load configuration definition load DWR configuration
Define session expiration configuration definition custom default 404, 500 page definition Application support Distributed Deployment Configuration definition MyBatis Configuration definition Context Listener configuration full Web.xml configuration content

    <context-param>         <param-name> contextconfiglocation</param-name>         <param-value>classpath*:/ spring/spring-content.xml</param-value>     </context-param>     < listener>         <listener-class> Org.springframework.web.context.contextloaderlistener</listener-class>     </listener >     <listener>           <listener-class>   & nbsp;           Org.springframework.web.context.request.RequestContextListener           </  
        listener-class>       </listener> <!--log4j configuration file loading--> <context-param> <param-name>log4jConfigLocation</param-name> <paRam-value>classpath:setup/log4j.xml</param-value> </context-param> <!--start Log4jconfigl Istener Listeners monitor log4j.xml configuration file changes every 60s--> <context-param> <param-name>log4jrefreshinterval</  
        param-name> <param-value>60000</param-value> </context-param> <listener> <listener-class> Org.springframework.web.util.Log4jConfigListener &LT;/LISTENER-CL Ass> </listener>     <!--log4j.properites loading log4j-->     <contex t-param>         <param-name>log4jConfigLocation</param-name>          <param-value>classpath:log/console.properties</param-value>      </context-param>     <context-param>          <param-name>log4jrefreshinterval</param-name>         <!--Spring Default Refresh log4j profile interval, unit millisecond-->          <param-value>60000</param-value>     </context-param>      <listener>         <listener-class>

Org.springframework.web.util.log4jconfiglistener</listener-class>     </listener>     <!--logback configuration    -->     <context-param>    & nbsp;    <param-name>logbackConfigLocation</param-name>          <param-value>classpath:logback.xml</param-value>     </context-param >     <listener>         <listener-class>


Ch.qos.logback.ext.spring.web.logbackconfiglistener</listener-class>     </listener>    <!--Start Application initialization listener applicationinitlistener--> <listener> <listener-class>com.rrtong.frame.application
        Initlistener</listener-class> </listener> <!--Spring MVC related configuration--> <servlet> <servlet-name>Dispatcher</servlet-name> <servlet-class> Org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name> Contextconfiglocation</param-name> <param-value>classpath:setup/applicationcontext-mvc.xml</par am-value> </init-param> <load-on-startup>1</load-on-startup>   </servlet> &nbs p;   <!--prevent spring memory overflow listener-->     <listener>       
 <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>     </listener>  <servlet-mapping> <servlet-naMe>dispatcher</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> < !--Define Filters--> <filter> <filter-name>set Character encoding</filter-name> <filter-class>or G.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>set Character encoding</filter-name> <url-pattern>*.do</ Url-pattern> </filter-mapping> <!--define default page--> <welcome-file-list> <welcome- File>index.jsp</welcome-file> </welcome-file-list> <!--custom Jstl tag function--> <jsp-config&
        Gt <taglib> <taglib-uri>http://tags.rrtong.com/pj</taglib-uri> <taglib-location>/web-inf/js Tl/custom.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jsp/jstl/rrtong</ taglib-uri> <taglib-location>/WEB-INF/jstl/unescape.tld</taglib-location> </taglib> </ Jsp-config> <!--definition Verification code--> <servlet> <servlet-name>Kaptcha</servlet-name> & Lt;servlet-class>com.google.code.kaptcha.servlet.kaptchaservlet</servlet-class> </servlet> < Servlet-mapping> <servlet-name>Kaptcha</servlet-name> <url-pattern>/kaptcha.jpg</url-p Attern> </servlet-mapping> <!--loading dwr-->     <servlet>    &nbsp ;    <servlet-name>dwr-invoker</servlet-name>          <servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>          <init-param>             <!--dwr test page, set to False on line-->              <param-name>debug</param-name>             < param-value>true</param-value>         </init-param>         <!--dwr intercept-->         <init-param>    & nbsp;        <param-name>org.directwebremoting.extend.remoter</param-name >             <param-value> com.pinhuba.web.filter.dwrremoter.dwrremoter</param-value>         </ init-param>         <init-param>              <!--prevent other domains from submitting Access-->             <param-name> Crossdomainsessionsecurity</param-name>             <param-value>false</ param-value>         </init-param>         < !--compression js-->         <init-param>          & nbsp  <param-name>scriptCompressed</param-name>             <param-value>true</param-value>         </init-param>          <load-on-startup>1</load-on-startup>     </servlet > <!--define session expiration--> <session-config> <session-timeout>30</session-timeou T> </session-config> <!--Configure custom error pages--> <error-page> <error -code>404</error-code> <location>/error/404.html</location> </error-page> <error-page> <error-code>500</error-code>
    <location>/error/500.html</location> </error-page> <!--tomcat cluster configuration-->
 <display-name>rrtong</display-name> <distributable/>

If you read Param-value,getservletcontext (). Getinitparameter ("My_param") through Java, you can read the data.

    <context-param>
        <param-name>my_param</param-name>
        <param-value>hello</ Param-value>
    </context-param>

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.