spring mvc framework is based on model - view - controller design pattern which separates the application logic in to 3 layers.
dispatcher servlet - intercepts all the incoming requests to the application and consults handler mapping to distinguish the controller to be used.
handler mapping - is responsible for finding out the controller who can handle the incoming request. mapping of requested url and the controller class method is done by xml configuration or annotations.
controller - controller will directly use the application classes to process the business request and attach the output to a model. the model will be sent to the view to render. view resolver will take of identifying the view to be rendered.
view resolver - will find the physical file to be rendered from the logical file name sent by the controller.
view - are physical files which can be jsp, velocity template etc.
web.xml - is the web deployment descriptor. declares the contextloaderListner and dispatcherServlet with root-context.xml and servlet-context.xml. it specifies a url mapping for requests to be handled by dispatcher servlet.
root-context.xml - is loaded upon application startup by springs contextloadlistner class. specifies configuration for root spring container which will be shared by all the servlets and filters.
servlet-context.xml -
is loaded by dispatcher servlet. configurations in the servlet-context.xml is used by dispatcher servlet for all the request coming.
few configurations:
annotation driver - annotations or xml
resources mapping - maps static resourses like images, css which donot have to go through controllers.
internalresoursesviewresolver - tells the view resolver how to get the physical view name from logical name.
context:component-scan - packages to be scanned when using annotation based strategy.
Controller
@controller - specifies the class is a spring controller.
@RequestMapping - species the url to be handled by the method
Ref
http://www.codejava.net/frameworks/spring/spring-mvc-beginner-tutorial-with-spring-tool-suite-ide
Comments
Post a Comment