Back Forum Reply New

Simple config question

Hi all,

We have already defined the business layer using spring / hibernate , and are loading our config like so in web.xml :

Code:   lt;listenergt;       lt;listener-classgt;org..web.context.ContextLoaderListenerlt;/listener-classgt;   lt;/listenergt;
   lt;context-paramgt;      lt;param-namegt;contextConfigLocationlt;/param-namegt;     lt;param-valuegt;/WEB-INF/applicationContext.xml /WEB-INF/serviceContext.xml /WEB-INF/daoContext.xml /WEB-INF/acegisecurity.xml     lt;/param-valuegt;   lt;/context-paramgt;
Now of course to use the DispatcherServlet we have:

Code:      lt;servletgt;       lt;servlet-namegt;springMVClt;/servlet-namegt;       lt;servlet-classgt;org..web.servlet.DispatcherServletlt;/servlet-classgt;       lt;load-on-startupgt;1lt;/load-on-startupgt;   lt;/servletgt;     lt;servlet-mappinggt;       lt;servlet-namegt;springMVClt;/servlet-namegt;       lt;ucl-patterngt;*.formlt;/ucl-patterngt;   lt;/servlet-mappinggt;
Now my question is do I define springMVC-servlet.xml and let the dispatcher servlet pick it up? Will the DispatcherServlet know about the ContextLoaderListener ? Will the ContextLoaderListener be the Root WebApplicationContext and the DispatcherServlet a child of that ? All I really want is to do is define springMVC-servlet.xml to have BeanNameuclHandlerMapping and SimpleFormController, so I can then wire  those mvc beans into the business beans I defined to be loaded by ContextLoaderListener . Does this make sense?

Robert

I didn't even define anything in mine.  If you stay within the naming convention, Spring will pick up the files in the correct order and load them appropriatly.  The convention for spring MVC stuff is spring-servlet.xml.

Robert- Yes, the way you described it is correct.  The DispatcherServlet will create an ApplicationContext that is a child of the root WebApplicationContext configured by the ContextLoaderListener.  The child context can refer to any bean in the root context.  Also, do not add the springMVC-servlet.xml file to the contextConfigLocation setting.


Originally Posted by iksrazalAll I really want is to do is define springMVC-servlet.xml to have BeanNameuclHandlerMapping and SimpleFormController, so I can then wire  those mvc beans into the business beans I defined to be loaded by ContextLoaderListener. Does this make sense?

I don't know if you just typed it wrong, but from the quote it sounds like you want to inject your web beans into your business beans. You mean the other way around, right?Originally Posted by gdbolingIf you stay within the naming convention, Spring will pick up the files in the correct order and load them appropriatly. The convention for spring MVC stuff is spring-servlet.xml.

Like dgynn said, by default the file is [servlet-name]-servlet.xml. So you would name yours springMVC-servlet.xml (not spring-servlet.xml).

-Arthur Loder
¥
Back Forum Reply New