Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Explore the designs of the Spring MVC and WebFlux frameworks, and apply similar designs and techniques to your own code. Along with detailed analysis of the code and functionality, this book includes numerous tips and tricks to help you get the most out of Spring MVC, WebFlux, and Java-based web application development in general using Spring. You’ll see how Spring MVC is a modern web application framework built upon the latest Spring Framework 5 and Spring Boot 2. Spring MVC is suitable for building reusable web controller modules that encapsulate rich page navigation rules.

Pro Spring MVC with WebFlux takes great care in covering every inch of Spring MVC with WebFlux to give you the complete picture. Along with all the best-known features of these frameworks, you’ll discover some new hidden treasures. You’ll also learn how to correctly and safely extend the frameworks to create customized solutions. 

This book is for anyone who wishes to write robust, modern, and useful web applications with the Spring Framework. After reading and using this book, you'll become proficient with Spring MVC and be able to apply it to your own Java web applications and microservices.

What You Will Learn

  • Use Spring MVC with WebFlux to build Java-based web applications
  • Employ the various Spring MVC architectures
  • Work with controllers and routing functions
  • Build microservices and web services using Spring MVC and REST
  • Create reactive web applications using Spring WebFlux
  • Secure Spring MVC and Spring WebFlux
  • Deploy your Spring MVC application to the cloud


Who This Book Is For

Those with at least some prior experience with Java web application development. Some previous experience with Spring Boot or the Spring Framework is recommended. 

Author(s): Marten Deinum
Edition: 2
Publisher: Apress
Year: 2021

Language: English
Commentary: True PDF
Pages: 596

Table of Contents
About the Authors
About the Technical Reviewer
Acknowledgments
Chapter 1: Setting up a Local Development Environment
Install the Java SDK
Install Gradle
Install Apache Tomcat
Recommended IDE
The Bookstore Project
Building the Project
Running the Projects
Summary
Chapter 2: Spring Framework Fundamentals
The Spring Framework
Dependency Injection
ApplicationContexts
Resource Loading
Component Scanning
Scopes
Profiles
Enabling Features
Aspect-Oriented Programming
Web Applications
Spring Boot
Summary
Chapter 3: Web Application Architecture
The MVC Pattern
Application Layering
Separation of Concerns
Spring MVC Application Layers
The Domain Layer
The User Interface Layer
The Web Layer
The Service Layer
The Data Access Layer
More Roads to Rome
Summary
Chapter 4: Spring MVC Architecture
DispatcherServlet Request Processing Workflow
The Workflow
Prepare a Request
Determine the Handler Execution Chain
Execute the Handler Execution Chain
Handler Exceptions
Render a View
Finish the Processing
The Request Processing Summary
DispatcherServlet
Bootstrapping DispatcherServlet
Using web.xml
Using web-fragment.xml
Using ServletContainerInitializer
Using WebApplicationInitializer
Using Spring Boot
Configuring DispatcherServlet
DispatcherServlet Properties
The Application Context
Component Resolution
DispatcherServlet’s Default Configuration
The Spring Boot Defaults
The Spring MVC Components
HandlerMapping
BeanNameUrlHandlerMapping
SimpleUrlHandlerMapping
RequestMappingHandlerMapping
RouterFunctionMapping
HandlerAdapter
HttpRequestHandlerAdapter
SimpleControllerHandlerAdapter
SimpleServletHandlerAdapter
HandlerFunctionAdapter
RequestMappingHandlerAdapter
MultipartResolver
CommonsMultipartResolver
StandardServletMultipartResolver
LocaleResolver
AcceptHeaderLocaleResolver
CookieLocaleResolver
FixedLocaleResolver
SessionLocaleResolver
ThemeResolver
CookieThemeResolver
FixedThemeResolver
SessionThemeResolver
HandlerExceptionResolver
RequestToViewNameTranslator
ViewResolver
FlashMapManager
Summary
Chapter 5: Implementing Controllers
Introducing Controllers
Interface-based Controllers
Annotation-based Controllers
Configuring View Controllers
Request-Handling Methods
Supported Method Argument Types
RedirectAttributes
UriComponentsBuilder
Supported Method Argument Annotations
RequestParam
RequestHeader
RequestBody
RequestPart
ModelAttribute
PathVariable
CookieValue
SessionAttribute
RequestAttribtue
Supported Method Return Values
Writing Annotation-based Controllers
A Simple Login Controller
Book Search Page
Book Detail Page
Data Binding
Customizing Data Binding
Global Customization
Per Controller Customization
ModelAttributes
Using ModelAttribute on Methods
Using ModelAttribute on Method Arguments
Using SessionAttributes
Thymeleaf expressions
Type Conversion
Property Editors
Converters
Formatters
Configuring Type Conversion
Using Type Conversion
Validating Model Attributes
Implementing Our Validator
Using JSR-303 Validation
Internationalization
Message Source
LocaleResolver
LocaleChangeInterceptor
Summary
Chapter 6: Implementing Controllers: Advanced
Using Scoped Beans
Adding Something to the Cart
Implementing the Checkout
Cross-cutting Concerns
Interceptors
Configuring Interceptors
Explicitly Configuring a Handler Mapping with Interceptors Using BeanPostProcessor
Using the InterceptorRegistry
Implementing an Interceptor
Implement WebRequestInterceptor
Implementing a Handler Interceptor
Exception Handling
DefaultHandlerExceptionResolver
ResponseStatusExceptionResolver
SimpleMappingExceptionResolver
ExceptionHandlerExceptionResolver
Extending Spring @MVC
Extending RequestMappingHandlerMapping
Extending the RequestMappingHandlerAdapter
HandlerMethodArgumentResolver
HandlerMethodReturnValueHandler
Implementing Your Own
Using the RequestDataValueProcessor
Summary
Chapter 7: REST and AJAX
REpresentational State Transfer (REST)
Identifying Resources
Working with Resources
HiddenHttpMethodFilter
Asynchronous JavaScript and XML (AJAX)
Adding AJAX to Our Application
AJAX Form Submit with HTML Result
AJAX Form Submit with JSON Result
Sending and Receiving JSON
Combining AJAX and REST
Progressive Enhancement
Handling File Uploads
Configuration
Configuring Servlet API File Uploading
Configuring Apache Commons File Uploading
Request Handling Method for File Upload
Writing a Request Handling Method with Multipart File
Using MultipartHttpServletRequest to Handle File Uploads
Using a Form Object to Handle Uploads
Writing a Request Handling Method Using the Servlet API
Exception Handling
Summary
Chapter 8: Resolving and Implementing Views
View Resolvers and Views
View Resolvers
BeanNameViewResolver
UrlBasedViewResolver
InternalResourceViewResolver
XsltViewResolver
ContentNegotiatingViewResolver
Implementing Your Own ViewResolver
View Technologies
JavaServer Pages
Tiles
Configuring Tiles
Configuring and Creating Templates
FreeMarker and Thymeleaf
Configuring the Template Engine
The Templating Language
PDF
Excel
XML and JSON
Summary
Chapter 9: Introduction to Spring WebFlux
HTTP Request Handling
Building Reactive Applications
Introduction to Reactive Programming
Programming with Streams
Reactive Streams
Using Project Reactor
Introduction to Spring WebFlux
Spring WebFlux Configuration: Reactive Controllers
Spring Boot WebFlux Application
Spring WebFlux Configuration: Functional Endpoints
Summary
Chapter 10: Building Reactive Applications with Spring WebFlux
From Spring Web MVC to Spring WebFlux
Migrating the Data Access Layer
Migrating the Service Layer
Migrating the Web Layer
Configuration of a Reactive Templating Engine
Using Server-Sent Events (SSEs)
Introducing WebClient and WebTestClient
Internationalization
Internationalization Support Using the Accept-Language Header
Internationalization Support Using a Request Parameter and a Custom Implementation of LocaleContextResolver
Internationalization Support Using a Request Parameter and a Custom Implementation WebFilter
Validation, Type Conversion, and Error Handling
Summary
Chapter 11: Securing Spring WebFlux Applications
Backpressure
The WebSocket Protocol
Using the WebSocket API with a Non-Reactive Application
Using the WebSocket API with a Reactive Application
Handling Backpressure
The RSocket Protocol
WebFlux Security
Summary
Chapter 12: Spring Security
Security Basics
Minimal Spring Web Security
Using Spring Security
Configuring Authentication
Configuring Authorization
Configure Login and Logout
Securing Methods
Securing Spring Boot Web Applications
Summary
Chapter 13: Spring Applications in the Cloud
Application Architecture
Introducing the Monolith
Introducing Microservices
Moving to the Cloud: Yea or Nay?
Introducing Spring Cloud
Redesigning for the Cloud
Registration and Discovery Server
Developing a Microservice
Microservice Using a Database
Microservice with a Web Console
Sharing Classes
Summary
Index