Presentation is loading. Please wait.

Presentation is loading. Please wait.

Spring 3.0 MVC - Introduction By, Srinivas Reddy.S www.JAVA9S.com.

Similar presentations


Presentation on theme: "Spring 3.0 MVC - Introduction By, Srinivas Reddy.S www.JAVA9S.com."— Presentation transcript:

1 Spring 3.0 MVC - Introduction By, Srinivas Reddy.S www.JAVA9S.com

2 Advantages of Spring 3.0 MVC Supports RESTful URLs. Annotation based configuration. Supports to plug with other MVC frameworks like Struts etc. Flexible in supporting different view types like JSP, velocity, XML, PDF etc., www.JAVA9S.com

3 MVC – An overview Controller View Model Request Response www.JAVA9S.com

4 Front Controller www.JAVA9S.com

5 Front Controller - Responsiblities Initialize the framework to cater to the requests. Load the map of all the URLs and the components responsible to handle the request. Prepare the map for the views. www.JAVA9S.com

6 Spring 3 MVC- Basic Architecture Dispacther Servlet (Front controller) HandlerMapping (Map of URL and controllers) Controller (Responsible to handle request) View (JSP, XML, Velocity) Model (POJO) Request 1 5 4 3 2 www.JAVA9S.com

7 Spring 3.0 MVC Request Flow DispatcherServlet Capture the Request Locale If request is multipart- File upload data is exposed HandlerMapping (Map of URL and controllers) Handler Chain Interceptor - Pre Process Interceptor - Pre Process Controller Interceptor - Post Process Interceptor - Post Process View Resolver Prepare the View Request Response

8 Spring 3 MVC Framework- Initialization Dispatcher Servlet - Initialization MultipartResolver LocaleResolver ThemeResolver HandlerMappings HandlerAdapters HandlerExceptionResolvers RequestToViewNameTranslator ViewResolvers

9 Important Intefaces InterfaceDefault bean namepurpose org.springframework.web.servlet. HandlerMapping handlerMappingMaps the Request to Handlers(Controllers) org.springframework.web.servlet. HandlerAdapter nonePlugs the other frameworks handlers org.springframework.web.servlet. ViewResolver viewResolverMaps the view names to view instances org.springframework.web.servlet. HandlerExceptionResolver handlerExceptionRes olver Mapping of the exceptions to handlers and views org.springframework.web.multip art. MultipartResolver multipartResolverInterface to handle the file uploads org.springframework.web.servlet. LocaleResolver localeResolverHelps to resolve the locale from the request org.springframework.web.servlet. ThemeResolver themeResolverResolves a theme for a Request.

10 Spring 3.0 MVC Configuration Step 1: – Configure the web.xml with DispatcherServlet and details of the application context file location. spring3 org.springframework.web.servlet.DispatcherServlet 1 spring3 *.* www.JAVA9S.com

11 Spring 3.0 MVC Configuration Step 2: – Configure the contextConfigLocation for the application context to be loaded contextConfigLocation /WEB-INF/spring3-service.xml org.springframework.web.context.ContextLoaderListener www.JAVA9S.com

12 Spring 3.0 MVC Configuration Step 3: Configure the spring3-servlet.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="com.java9s.web" /> <bean class="org.springframework.web.servlet.mvc.annotation. DefaultAnnotationHandlerMapping" /> <bean class="org.springframework.web.servlet.mvc.annotation. AnnotationMethodHandlerAdapter" /> www.JAVA9S.com

13 Thank you visit www.java9s.com


Download ppt "Spring 3.0 MVC - Introduction By, Srinivas Reddy.S www.JAVA9S.com."

Similar presentations


Ads by Google