Is it possible to run spring-orm program using dispatcher-servlet.xml only. Without using ContextLoaderListener and applicationcontext.xml? If yes then how?
Secondly why is it necessary to register dispatcher-servlet.xml or applicationcontext.xml in web.xml? Because when these files are not registered in web.xml all the setter injections(specified in dispatcher-servlet.xml or applicationcontext.xml) take place on server start-up that means these xml files are loading without registering in web.xml.
Yes, that’s fine.
You just do it. Put everything you need into
dispatcher-servlet.xml, it’ll operate on its own. While it’s common practice to put DAO-related stuff inapplicationContext.xmland MVC stuff indispatcher-servlet.xml, it’s by no means a requirement. It can all sit in one file if you choose.Because if you don’t specify them in
web.xml, Spring will use its defaults and look for them anyway.DispatcherServletwill look for<servlet-name>-servlet.xml, andContextLoaderListenerwill look for/WEB-INF/applicationContext.xmlby default. You can override this inweb.xmlif you choose.