Reputation: 1712
I have to develop a full fledged project. by full fledged i mean need to insert, update delete values in a database, Performing operations on values. Its like i have set of model classes for every object. Employee, products etc. its a web application developed using Spring MVC. I know when a user enters a data in a form , the request goes to dispatcher servlet from there to a particular handler(Controller) and then to view. But i don't know what application Context or web Application Context does ? its like is it necessary to have that xml file. ? What all it contains. thanks ...
Upvotes: 2
Views: 248
Reputation: 340983
You are right in your assumptions. What you don't know is that DispatcherServlet
has its own context, defined in *-servlet.xml
. This context is typically a child of a main application context, typically defined in applicationContext.xml
. Child can access all beans defined in parent context but not the other way around.
Theoretically you can live with just a single DispatcherServlet
context and have all beans there (DAOs, services, transaction demarcation). But this is a poor practice in a bigger projects. Also two context allow you to draw a line between business logic and web layer.
Practical implication - if you have two DispatcherServlet
s there is no way of sharing beans between them if they don't have a common parent context.
Upvotes: 3