Spring / Spring MVC Interview questions
Can we have multiple Spring configuration files in Spring MVC?
Yes, we can have more than one spring context files. The following are the 2 ways to configure multiple context files.
1. Specify the list of files in web.xml file using contextConfigLocation init parameter.
<servlet-name>springMVC</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> WEB-INF/spring-core-context.xml, WEB-INF/spring-DAO.xml, WEB-INF/spring-Services.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
2. Import the configuration files into a existing configuration file that is already configured.
<beans> <import resource="spring-core-context.xml"/> <import resource="spring-DAO.xml"/> <import resource="spring-services.xml"/> ... //other configurations </beans>
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
