Customizing the spring configuration file location

Source: Internet
Author: User




Spring configuration file Springtest.xml Transfer location

Look at the Web. config file location

<!--SPRINGMVC configuration-  <servlet>  <servlet-name>springMVC</servlet-name>  < Servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>    <!-- You can customize the location and name of the Servlet.xml configuration file by default to the Web-inf directory with the name [<servlet-name>]-servlet.xml, such as spring-servlet.xml-->< init-param><param-name>contextconfiglocation</param-name><!--here <span style= "font-family: Arial, Helvetica, Sans-serif; >param-name</span> name must be <span style= "font-family:arial, Helvetica, Sans-serif;" >contextconfiglocation</span>--><param-value>classpath:springconfig/springtest.xml</ param-value></init-param>  <load-on-startup>1</load-on-startup>  </servlet>  <servlet-mapping>  <servlet-name>springmvc</servlet-name><url-pattern>*.spring </url-pattern>    </servlet-mapping>  


1) The Load-on-startup element flags whether the container loads the servlet at startup (instantiating and invoking its init () method).

2) Its value must be an integer indicating the order in which the servlet should be loaded

2) A value of 0 or greater than 0 o'clock indicates that the container loads and initializes the servlet when the application is started;

3) When the value is less than 0 or unspecified, the container will not load until the servlet is selected.

4) The lower the value of a positive number, the higher the precedence of the servlet, and the more loaded it will be when the app starts.

5) At the same time, the container will be loaded in its own order of choice.


Optional configuration

<!--spring configuration--><!--======================================--><listener>   <listenerclass >     org.springframework.web.context.ContextLoaderListener   </listener-class></listener>  <!--Specifies the directory where the spring bean's configuration file resides. Default configuration in Web-inf directory--><context-param>    <param-name>contextConfigLocation</param-name>    <param-value><span style= "font-family:arial, Helvetica, Sans-serif;" >classpath:springconfig/</span><span style= "font-family: ' Courier New '; line-height:18px; White-space:pre-wrap; " >applicationContext.xml</span></param-value></context-param>



Customizing the spring configuration file location

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.