1 / 13

Spring 3.0 MVC - Introduction

Spring 3.0 MVC - Introduction. By, Srinivas Reddy.S. www.JAVA9S.com. Advantages of Spring 3.0 MVC. Supports RESTful URLs. Annotation based configuration. Supports to plug with other MVC frameworks like Struts etc.

liuz
Download Presentation

Spring 3.0 MVC - Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Spring 3.0 MVC - Introduction By, SrinivasReddy.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 Model Controller Request View Response www.JAVA9S.com

  4. Front Controller 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 HandlerMapping (Map of URL and controllers) 2 DispactherServlet (Front controller) Controller (Responsible to handle request) 3 Request 1 4 Model (POJO) 5 View (JSP, XML, Velocity) www.JAVA9S.com

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

  8. Spring 3 MVC Framework-Initialization DispatcherServlet -Initialization MultipartResolver LocaleResolver ThemeResolver HandlerMappings HandlerAdapters HandlerExceptionResolvers RequestToViewNameTranslator ViewResolvers

  9. Important Intefaces

  10. Spring 3.0 MVC Configuration • Step 1: • Configure the web.xml with DispatcherServlet and details of the application context file location. <servlet> <servlet-name>spring3</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring3</servlet-name> <url-pattern>*.*</url-pattern> </servlet-mapping> www.JAVA9S.com

  11. Spring 3.0 MVC Configuration • Step 2: • Configure the contextConfigLocation for the application context to be loaded <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring3-service.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> 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" /> </beans> www.JAVA9S.com

  13. Thank youvisit www.java9s.com

More Related