

web.xml is used to instantiate spring web application context.web.config package is to load MVC related configuration.app.confg package is to load Database, Transaction Management configuration.create the project structure like below:.Create Maven Project and select as simple arche type.: is shortcut for RequestMapping(method = RequestMethod.DELETE) Spring 4 MVC Maven example.: is shortcut for RequestMapping(method = RequestMethod.PUT).: is shortcut for RequestMapping(method = RequestMethod.POST).: is shortcut for RequestMapping(method = RequestMethod.GET).Public ModalAndView doLoginAcion(HttpServletRequest request,HttpServletResponse response) method = RequestMethod.GET) class UserController final UserService = RequestMethod.GET).annotation is used to map URLs such as /home, /login.action on class or a handler method.is used to auto create spring bean rather to define in xml and playsthe role of a controller.It enables support for annotation based MVC, so that it scans for and to create request handler mappings.enables Spring MVC configuration and same as tag in xml configuration.have a look into details of some of the annotations:.The following are available spring MVC annotations in Spring 4. Click here to access Spring MVC Tutorial using XML configuration-tutorial that explained with Login Form. XML bean configuration : This is widely used in spring 3 versions.In this tutorial, we will see Spring MVC with Java annotations configuration Java annotations configuration : Spring provides annotations to create configure IOC and beans.Spring supports two types of configuration loading IOC container to instantiate beans: provide contextConfigLocation path in init config, otherwise it will look for “spring-dispatcher-servlet.xml” in class path.contextConfigLocation: provide xml configuration and config package path for java based config.contextClass : by default it used XmlWebApplicationContext.RootApplicationContext is app spring container holds all core beans such as services,dao,modal etc.WebApplicationContext is Web spring container holds all MVC related beans.Each Dispatcher Servlet has its own WebApplicationContext that extends RootAppliactionContext.if no mapping found then it returns 404 resource not found error.Older versions of spring are required to configure Handler Mappings, but in new versions has RequestMappingHandlerMapping annotation looks annotations on all Dispatcher Servlet again delegates the request to controller based on Annotation values and invokes the method if any request mapping found. Dispatcher Servlet looks for controller in handler mapping and gets the controller for URL mapping.“Spring Dispatcher” Servlet will be invoked for each URL request that ends with “*.action”.Dispatcher Servlet is HttpServlet that configured in web.xml like below along with servlet mapping.Spring dispatcher servlet is responsible for dispatching request to corresponding request handlers.Spring MVC framework is designed on request response modal around Dispatcher Servlet, that dispatches request to Controller and it is integrated with Spring IOC to load other spring beans. As you all know, Spring Web MVC(Modal View Controller) designed around DispatcherServlet that responsible for handling requests on server. Spring 4 MVC Maven example helps to develop MVC applications with spring Java configurations.
