文档详情

《Mastering Spring MVC 3》.pdf

发布:2015-12-29约1.76万字共41页下载文档
文本预览下载声明
Mastering Spring MVC 3 And its @Controller programming model Get the code for the demos in this presentation at • /svn/spring-samples/mvc-showcase © 2010© 2010 SpringSource, A division of SpringSource, A division of VMware. All rights reserved VMware. All rights reserved Topics  Getting started  Introduction to the MVC programming model  Mapping HTTP requests  Obtaining request input  Generating responses  Rendering views  Type conversion, validation, forms, and file upload  Exception handling  Testing 2 Getting started  Create a new Spring MVC project from a template • Most use Roo to do this, either from an IDE like STS or the command-line Typical setup:  One DispatcherServlet registered in web.xml • FrontController that dispatches web requests to your application logic • Generally the “default servlet” mapped to “/”  Two Spring Containers (or ApplicationContexts) instantiated • 1 “root” context to host “shared resources” required by Servlets / Filters • 1 “web” context to host local application components delegated to by the DispatcherServlet • Your application components are typically discovered via classpath scanning 3 Demo Typical Spring MVC project structure 4 Introduction to the MVC programming model  DispatcherServlet requests are mapped to @Controller methods • @RequestMapping annotation used to define mapping rules • Method parameters used to obtain request input • Method return values used to generate responses  Simplest possible @Controller @
显示全部
相似文档