Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6548171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:55:09+00:00 2026-05-25T11:55:09+00:00

I have to load 3 spring config xml files in myproj spring mvc app

  • 0

I have to load 3 spring config xml files in myproj spring mvc app named myproj-controllers.xml, myproj-services.xml and myproj-dao.xml. I have two options to load them.

Firstly Use import resources in myproj-servlet.xml

<import resource="myproj-controllers.xml"/>
<import resource="myproj-services.xml"/>
<import resource="myproj-dao.xml"/>

or secondly in the web.xml using context param like this

<context-param>
   <param-name>contextConfigLocation</param-name>
   <param-values>/WEB-INF/myproj-controllers.xml</param-values>
   <param-values>/WEB-INF/myproj-services.xml</param-values>
   <param-values>/WEB-INF/myproj-dao.xml</param-values>
</context-param>

and adding ContextLoader listener

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

Which approach is recommend? And why? In my opinion I find import approach easier as we only need to make changes to myproj-servlet.xml instead of web.xml.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:55:10+00:00Added an answer on May 25, 2026 at 11:55 am

    Spring lets you declare multiple contexts in a parent-child relation so I always went for one root applicationContext.xml containing my application beans (services, DAOs etc) and one action-servlet.xml for servlet contexts (request mappings, view resolvers etc).

    I once needed action-servlet-2.xml file but still had just one root applicationContext.xml for both servlet contexts.

    So (for me) it was always parent context + child context.

    The only need for splitting the files into more pieces was just to reduce the size of the XMLs (which is what <import> does best).

    For me, the contextConfigLocation param refers to application context files being loaded together into a single application context instance. But your files (myproj-controllers.xml, myproj-services.xml, myproj-dao.xml) seem like parts of one application context file.

    For this reason I would personally go for the <import> statements and have just one value (for the root application context) in the contextConfigLocation param.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large application spread across multiple Spring bean definition xml files. In
I am new to spring security I have web.xml <?xml version=1.0 encoding=UTF-8?> <web-app xmlns=http://java.sun.com/xml/ns/javaee
i have an UITableView in my app and i have to load some images
I want to define two servlets in my Spring web.xml - one for the
I have a pretty simple JSP/Servlet 3.0/Spring MVC 3.1 application. On one of my
What is the correct way to split Spring's configuration to multiple xml files? At
I'm starting with Spring Web MVC. I have very simple controller and view, but
i am using PrettyFaces 3.3.0 with Spring Security 3 i have two beans UserBean
I am trying to load up an XML document in MVC in the HomeController
I have: String uri = @drawable/myresource.png; How can I load that in ImageView? this.setImageDrawable?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.