Book description
Unleash the power of Spring MVC and build enterprise-grade, lightning-fast web applications
About This Book
Configure Spring MVC to build logic-less controllers that transparently support the most advanced web techniques
Secure your developments with easy-to-write, reliable unit and end-to-end tests
Get this fast-paced, practical guide to produce REST resources and templates as required by the latest front-end best practices
Who This Book Is For
This Learning Path is for Java developers who want to exploit Spring MVC and its features to build web applications. It will help you step up in your career and stay up to date or learn more about Spring’s web scalability.
What You Will Learn
Set up and build standalone and web-based projects using Spring Framework with Maven or Gradle
Develop RESTful API applications for XML and JSON data transfers
Investigate Spring data access mechanisms with Spring Data Repositories
Generate templates for a responsive and powerful front end with AngularJS and Bootstrap
Authenticate over REST with a BASIC authentication scheme and OAuth2; handle roles and permissions
Communicate through WebSocket and STOMP messages
Design complex advanced-level forms and validate the model
Create maintainable unit and acceptance tests to secure the apps
Deploy the web application to the cloud in a snap
In Detail
Spring MVC helps you build flexible and loosely coupled web applications. The Spring MVC Framework is designed in such a way that every piece of logic and functionality is highly configurable. This Learning Path aims to make you an expert in designing web applications with Spring MVC 4.
In our first module, we’ll begin with an introduction to the Spring framework. You'll then learn aspect-oriented programming. Packed with real-world examples, you’ll get an insight into how you can use Spring Expression Language in your applications to make them easier to manage and maintain.
In the second module, you'll learn everything you need to build modern Spring-based enterprise web applications. From practical development techniques and useful tools from the wider Spring ecosystem, to the new JEE standards, the impact of JavaScript, and even the Internet of Things, you'll feel confident that you can deploy Spring for an impressive range of creative purposes.
In the final module, you'll find out how to take advantage of Spring MVC's advanced features - essential if you are to properly master the framework. To do this you'll investigate the inner mechanics of Spring MVC, and how they tie into to the broader principles that inform many modern web architectures. With further guidance on how to test, secure, and optimize your application, as well as designing RESTful services, you'll very quickly be ready to use Spring in your next web project.
This Learning Path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products:
Spring Essentials by Shameer Kunjumohamed, Hamidreza Sattari
Spring MVC Cookbook by Alex Bretet
Mastering Spring MVC 4 by Geoffroy Warin
Style and approach
This is a hands-on, practical guide based on logical modules of the whole Spring framework family, employing a combination of theory and examples with pro-level practices, techniques, and solutions.
Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.
Table of contents
-
Spring MVC: Designing Real-World Web Applications
- Table of Contents
- Spring MVC: Designing Real-World Web Applications
- Spring MVC: Designing Real-World Web Applications
- Credits
- Preface
-
I. Module 1
-
1. Getting Started with Spring Core
- The Spring landscape
- Design concepts behind Spring Framework
- Setting up the development environment
- Your first Spring application
- Dependency Injection
-
Beans in detail
- Bean definition
- Instantiating beans
- Injecting bean dependencies
- Constructor-based or setter-based DI – which is better?
- Cleaner bean definitions with namespace shortcuts
- Wiring a List as a dependency
- Wiring a Map as a dependency
- Autowiring dependencies
- Bean scoping
- Dependency Injection with scoped beans
- Creating a custom scope
- Hooking to bean life cycles
- Container-level default-init-method and default-destroy-method
- Working with bean definition profiles
- Injecting properties into the Spring environment
- Externalizing properties with PropertyPlaceholderConfigurer
- Handling resources
- Spring Expression Language
- Aspect Oriented Programming
- Testing with Spring
- Summary
-
2. Building the Web Layer with Spring Web MVC
- Features of Spring MVC
- The Model-View-Controller pattern
- Your first Spring MVC application
- Setting up a Spring MVC application
- The architecture and components of Spring MVC
- DispatcherServlet explained
-
Controllers in detail
- Mapping request URLs with @RequestMapping
- URI template patterns with the @PathVariable annotation
- Binding parameters with the @RequestParam annotation
- Request handler method arguments
- Request handler method return types
- Setting Model attributes
- Building RESTful services for JSON and XML media
- Building a RESTful service with RestController
- Asynchronous request processing in Spring MVC
- Working with views
- Spring and Spring form tag libraries
- Composing a form in JSP
- Validating forms
- Handling file uploads
- Resolving Thymeleaf views
- More view technologies
- Summary
-
3. Accessing Data with Spring
- Configuring DataSource
- Using embedded databases
- Handling exceptions in the Spring Data layer
- DAO support and @Repository annotation
- Spring JDBC abstraction
- Spring Data
- Spring Transaction support
- Relevance of Spring Transaction
- Summary
- 4. Understanding WebSocket
- 5. Securing Your Applications
-
6. Building a Single-Page Spring Application
- The motivations behind SPAs
- SPAs explained
- Introducing Ember.js
- The anatomy of an Ember application
- Working with Ember CLI
- Understanding the Ember object model
- Working with collections
- Building UI templates using Handlebars
- Handling routes
- Handling UI behavior using components
- Persisting data with Ember Data
- Building a Taskify application
- Building the API server app
- Building the Taskify Ember app
- Summary
- 7. Integrating with Other Web Frameworks
-
1. Getting Started with Spring Core
-
II. Module 2
-
1. Setup Routine for an Enterprise Spring Application
- Introduction
- Installing Eclipse for JEE Developers and Java SE 8
- Configuring Eclipse for Java 8, Maven 3, and Tomcat 8
- Defining the project structure with Maven
- Installing Spring, Spring MVC, and a web structure
-
2. Designing a Microservice Architecture with Spring MVC
- Introduction
- Configuring a controller with simple URL mapping
- Configuring a fallback controller using ViewResolver
- Setting up and customizing a responsive single page webdesign with Bootstrap
- Displaying a model in the View, using the JSTL
- Defining a common WebContentInterceptor
- Designing a client-side MVC pattern with AngularJS
- 3. Working with Java Persistence and Entities
-
4. Building a REST API for a Stateless Architecture
- Introduction
- Binding requests and marshalling responses
- Configuring content-negotiation (JSON, XML, and so on)
- Adding pagination, filters, and sorting capabilities
- Handling exceptions globally
- Documenting and exposing an API with Swagger
-
5. Authenticating with Spring MVC
- Introduction
- Configuring Apache HTTP to proxy your Tomcat(s)
- Adapting users and roles to Spring Security
- Authenticating over a BASIC scheme
- Authenticating with a third-party OAuth2 scheme
- Storing credentials in a REST environment
- Authorizing on services and controllers
- 6. Implementing HATEOAS
-
7. Developing CRUD Operations and Validations
- Introduction
- Extending REST handlers to all HTTP methods
- Validating resources using bean validation support
- Internationalizing messages and contents for REST
- Validating client-side forms with HTML5 AngularJS
-
8. Communicating Through WebSockets and STOMP
- Introduction
- Streaming social events with STOMP over SockJS
- Using RabbitMQ as a multiprotocol message broker
- Stacking and consuming tasks with RabbitMQ and AMQP
-
Securing messages with Spring Session and Redis
- Getting ready
- How to do it…
- How it works...
- There's more…
- See also
-
9. Testing and Troubleshooting
- Introduction
- Automating Database Migrations with FlyWay
- Unit testing with Mockito and Maven Surefire
- Integration testing with Cargo, Rest-assured, and Maven failsafe
- Injecting Spring Beans into integration tests
- Modern application Logging with Log4j2
-
1. Setup Routine for an Enterprise Spring Application
-
III. Module 3
- 1. Mastering the MVC Architecture
- 2. Handling Forms and Complex URL Mapping
- 3. File Upload and Error Handling
- 4. Crafting a RESTful Application
- 5. Securing Your Application
- 6. Leaving Nothing to Luck – Unit Tests and Acceptance Tests
- 7. Optimizing Your Requests
- 8. Deploying Your Web Application to the Cloud
- 9. Beyond Spring Web
- A. Bibliography
- Index
Product information
- Title: Spring MVC: Designing Real-World Web Applications
- Author(s):
- Release date: November 2016
- Publisher(s): Packt Publishing
- ISBN: 9781787126398
You might also like
video
Spring MVC for Java Developers
This screencast is designed to teach novice-level Java developers how to efficiently build well structured Java …
video
Spring MVC For Beginners
Developing your first Spring MVC web application is fun. In this course, you will learn the …
book
Practical Vaadin: Developing Web Applications in Java
Implement web applications in Java using the open-source Vaadin framework version 20 and later. This easy-to-follow …
book
Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2
Explore the designs of the Spring MVC and WebFlux frameworks, and apply similar designs and techniques …