Announcement Announcement Module
Collapse
No announcement yet.
Loading Spring Configuration Files Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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."

      Comment


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

        Comment

        Working...
        X