Содержание
- 2. AGENDA
- 3. INTRODUCING MVC AND SPRING MVC
- 4. What is MVC? Introducing MVC and Spring MVC What is MVC?
- 5. Introduction to Web Spring MVC Spring MVC provides a clear separation between a model, view and
- 6. What is MVC? Introducing MVC and Spring MVC Spring MVC WebApplicationContext Hierarchy
- 7. What is MVC? Introducing MVC and Spring MVC Spring MVC WebApplicationContext Hierarchy
- 8. Introducing MVC and Spring MVC Spring MVC Request Life Cycle
- 9. Introducing MVC and Spring MVC Intercepting requests with a HandlerInterceptor
- 10. Introducing MVC and Spring MVC Spring MVC Request Life Cycle BeanNameViewResolver FreeMarkerViewResolver InternalResourceViewResolver JasperReportsViewResolver ResourceBundleViewResolver UrlBasedViewResolver
- 11. Introducing MVC and Spring MVC Spring MVC Configuration To configure Spring MVC support for web applications:
- 12. DISPATCHERSERVLET, CONTROLLER, VIEW, MODEL
- 13. DispatcherServlet, Controller, View, Model DispatcherServlet
- 14. DispatcherServlet, Controller, View, Model DispatcherServlet Code Overview xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> ...
- 15. DispatcherServlet, Controller, View, Model DispatcherServlet Code Overview
- 16. DispatcherServlet, Controller, View, Model DispatcherServlet Code Overview
- 17. DispatcherServlet, Controller, View, Model DispatcherServlet Code Overview
- 18. DispatcherServlet, Controller, View, Model DispatcherServlet Code Overview
- 19. DispatcherServlet, Controller, View, Model Controllers Controllers provide access to the application behavior that you typically define
- 20. DispatcherServlet, Controller, View, Model View Examples
- 21. DispatcherServlet, Controller, View, Model Model examples Map Populated by controllers Contains all data needed by the
- 22. DispatcherServlet, Controller, View, Model Supported method return types ModelAndView Model Map View String void ….
- 23. INTERNATIONALIZATION(I18N) / THEMES / TEMPLATES (APACHE TILES)
- 24. Internationalization(i18n) / Themes / Templates (Apache Tiles) Internationalization Enable i18n in the early stage. Properties files
- 25. Internationalization(i18n) / Themes / Templates (Apache Tiles) Configuring i18n in DispatcherServlet
- 26. Internationalization(i18n) / Themes / Templates (Apache Tiles) Configuring i18n in DispatcherServlet
- 27. Internationalization(i18n) / Themes / Templates (Apache Tiles) Configuring i18n in DispatcherServlet
- 28. Internationalization(i18n) / Themes / Templates (Apache Tiles) Example View
- 29. Internationalization(i18n) / Themes / Templates (Apache Tiles) Using Themes
- 30. Internationalization(i18n) / Themes / Templates (Apache Tiles) Using Themes FixedThemeResolver SessionThemeResolver CookieThemeResolver
- 31. Internationalization(i18n) / Themes / Templates (Apache Tiles) Using templates
- 32. MAPPING OF URLS, VALIDATION SUPPORT
- 33. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping
- 34. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping consumes consumes="application/json“; consumes=“!application/json“;
- 35. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping consumes consumes="application/json“; consumes=“!application/json“;
- 36. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping consumes consumes="application/json“; consumes=“!application/json“;
- 37. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping consumes consumes="application/json“; consumes=“!application/json“;
- 38. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping consumes consumes="application/json“; consumes=“!application/json“;
- 39. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping consumes consumes="application/json“; consumes=“!application/json“;
- 40. Mapping of URLs, Validation support (JSR-349) Mapping of URLs to the views @RequestMapping consumes consumes="application/json“; consumes=“!application/json“;
- 41. Mapping of URLs, Validation support (JSR-349) Mapping example
- 42. Mapping of URLs, Validation support (JSR-349) Mapping example
- 43. Mapping of URLs, Validation support (JSR-349) Mapping example
- 44. Mapping of URLs, Validation support (JSR-349) Mapping example
- 45. Mapping of URLs, Validation support (JSR-349) Mapping example
- 46. Mapping of URLs, Validation support (JSR-349) Mapping example
- 47. Mapping of URLs, Validation support (JSR-349) Mapping example
- 48. Mapping of URLs, Validation support (JSR-349) Mapping example
- 49. Mapping of URLs, Validation support (JSR-349) Mapping example
- 50. Mapping of URLs, Validation support (JSR-349) Mapping example /spring-web/spring-web-3.0.5.jar
- 51. Spring MVC Annotations Composed @RequestMapping Variants @GetMapping @PostMapping @PutMapping @DeleteMapping @PatchMapping @RequestMapping(method = RequestMethod.GET) public Map
- 52. Path Patterns /myPath/*.do
- 53. Path Patterns /myPath/*.do /owners/*/pets/{petId}
- 54. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/**
- 55. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/**
- 56. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/*
- 57. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/*
- 58. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/* /hotels/{hotel} /hotels/*
- 59. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/* /hotels/{hotel} /hotels/*
- 60. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/* /hotels/{hotel} /hotels/* /** /api/{a}/{b}/{c}
- 61. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/* /hotels/{hotel} /hotels/* /** /api/{a}/{b}/{c}
- 62. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/* /hotels/{hotel} /hotels/* /** /api/{a}/{b}/{c} /public/** /public/path3/{a}/{b}/{c}
- 63. Path Patterns /myPath/*.do /owners/*/pets/{petId} /hotels/{hotel}/* /hotels/{hotel}/** /foo/bar* /foo/* /hotels/{hotel} /hotels/* /** /api/{a}/{b}/{c} /public/** /public/path3/{a}/{b}/{c}
- 64. Spring MVC Annotations @RequestBody @PutMapping("/something") public void handle(@RequestBody String body, Writer writer) throws IOException { writer.write(body);
- 65. Spring MVC Annotations @ResponseBody @GetMapping("/something") @ResponseBody public String helloWorld() { return "Hello World"; } HttpMessageConverter
- 66. Spring MVC Annotations @RestController @RestController
- 67. Spring MVC Annotations @ModelAttribute on a method // Add one attribute // The return value of
- 68. Spring MVC Annotations @ModelAttribute on method arguments @PostMapping("/owners/{ownerId}/pets/{petId}/edit") public String processSubmit(@ModelAttribute Pet pet) { }
- 69. Content Negotiation
- 70. Mapping of URLs, Validation support (JSR-349) Configure JSR-349, “Bean Validation” @Entity @Table(name = "contact") public class
- 71. Mapping of URLs, Validation support (JSR-349) Configure JSR-349, “Bean Validation” public String update(@Valid Contact contact, ...
- 72. FILE UPLOAD HANDLING
- 73. File Upload Handling Overview Tomcat 7 -> Servlet 3.0 -> Spring 3.1 Apache Commons FileUpload
- 74. File Upload Handling Enable File Upload support
- 75. File Upload Handling Enable File Upload support
- 76. File Upload Handling Modifying Views for File Upload Support
- 77. File Upload Handling Modifying Views for File Upload Support
- 78. File Upload Handling Modifying Views for File Upload Support
- 79. SUPPORTING SERVLET 3.0 CODE-BASED (JAVA-BASED) CONFIGURATION
- 80. Supporting Servlet 3.0 Code-Based (Java-Based) Configuration Configuration Advantages?
- 81. Supporting Servlet 3.0 Code-Based (Java-Based) Configuration Configuration Advantages? Java синтаксис Code IDE advantages Flexibility No need
- 82. Supporting Servlet 3.0 Code-Based (Java-Based) Configuration Configuration org.springframework.web.WebApplicationInitializer org.springframework.web.SpringServletContainerInitializer Advantages? Java синтаксис Code IDE advantages Flexibility
- 83. Supporting Servlet 3.0 Code-Based (Java-Based) Configuration Configuration public class MyWebAppInitializer implements WebApplicationInitializer { @Override public void
- 84. Supporting Servlet 3.0 Code-Based (Java-Based) Configuration Configuration public class MyWebAppInitializer implements WebApplicationInitializer { @Override public void
- 85. HANDLING EXCEPTIONS
- 86. Handling exceptions Dealing with exceptions Exceptions -> Status Codes org.springframework.web.servlet.HandlerExceptionResolver: Exception -> ModelAndView SimpleMappingExceptionResolver: Exceptions ->
- 87. Handling exceptions @ExceptionHandler & @ResponseStatus @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(DataAccessException.class) public void handleDataAccessError(DataAccessException ex) {} @ResponseStatus(value = HttpStatus.PAYMENT_REQUIRED, message
- 88. SPRING MVC AND SPRING SECURITY
- 89. Spring MVC and Spring Security Introduction Declaration Security Support for many authentication and authorization schemes, such
- 90. Spring MVC and Spring Security Libraries Maven Dependencies for Spring Security
- 91. Spring MVC and Spring Security Configuring Spring Security Configure a filter in the web deployment descriptor:
- 92. Spring MVC and Spring Security Configuring Spring Security
- 93. Spring MVC and Spring Security Adding Login Functions to the Application
- 94. Spring MVC and Spring Security Enable Method-Level Security
- 95. Spring MVC and Spring Security Enable Method-Level Security
- 96. HELPFUL LINKS http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller http://en.wikipedia.org/wiki/Spring_Framework#Model-view-controller_framework
- 98. Скачать презентацию