Results 1 to 4 of 4

Thread: Loading Spring Configuration Files

  1. #1
    Join Date
    Dec 2011
    Posts
    13

    Default Loading Spring Configuration Files

    Hi All,

    I was creating simple Spring application in Netbeans 7.1 and I notice two application context files: applicationContext.xml and dispatcher-servelt.xml. It is good practice to split our application context across multiple XML files and we can set them as contextConfigLocation parameters. I got this part but when I check web.xml file I can see only

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

    Isn't that true that we need to give all list of xml files as parameter? Or i am missing something.

    Thanks,
    Anjib

  2. #2
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    The "contextConfigLocation" parameter value can override the default value of "/WEB-INF/applicationContext.xml". As your value is the same as the default, you could have omitted that setting entirely. This value is used to initialize the base context.

    The other context, which you've named "dispatcher-servlet.xml", is specifically for the context associated with the DispatcherServlet, which you obviously named "dispatcher" in your web.xml. This servlet also looks for a "contextConfigLocation" parameter, to specify additional context locations.

    Typically, you would put definitions specific to MVC or servlet requests in the "dispatcher-servlet.xml" context, and put other things in the base "applicationContext.xml".

    Read the Spring documentation for more information about this.

  3. #3
    Join Date
    Dec 2011
    Posts
    13

    Default Relation between applicationContext.xml and other xml files

    So my quetion will be what is diference/relation between applicationContext.xml and other xml like

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/dispatcher-servlet.xml
    /WEB-INF/dispatcher-service.xml
    /WEB-INF/dispatcher-data.xml
    /WEB-INF/dispatcher-security.xml
    </param-value>
    </context-param>

    "This (dispatcher-servlet.xml) servlet also looks for a "contextConfigLocation" parameter, to specify additional context locations."

  4. #4
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    284

    Default

    Read the Spring documentation for more information about this.
    http://static.springsource.org/sprin...ml#mvc-servlet
    Amila Domingo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •