spring newbie doubt

J

jimgardener

hi
I was trying out spring example in A.Hemrajani's book.
The example creates two application context xml files timex-
servlet.xml,and springtest-applicationcontext.xml both in src/conf
directory and which will be copied to WEB-INF directory during build.

In test code ,this is invoked
new FileSystemXmlApplicationContext("src/conf/springtest-
applicationcontext.xml");

but nowhere in the code, the other xml file ( timex-servlet.xml) is
used like above.Instead the author says,
'Our Spring application context file, timex-servlet.xml, will
automatically be searched for and loaded by Spring for us.'

How does this happen?Can someone explain?

regards,
jim
 
G

Graham Cox

jimgardener said:
but nowhere in the code, the other xml file ( timex-servlet.xml) is
used like above.Instead the author says,
'Our Spring application context file, timex-servlet.xml, will
automatically be searched for and loaded by Spring for us.'

How does this happen?Can someone explain?

If you read "13.2. The DispatcherServlet" of the Spring Web MVC Manual
(http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html) then
this will explain it to you. Essentially, when you configure up a servlet
called "timex" using the DispatcherServlet class then by default it will
use the "timex-servlet.xml" file for it's spring configuration. You can
override that if you wish though...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top