Spring MVC Cookbook
eBook - ePub

Spring MVC Cookbook

  1. 466 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Spring MVC Cookbook

About this book

Over 40 recipes for creating cloud-ready Java web applications with Spring MVC

About This Book

  • Configure Spring MVC to build logic-less controllers that transparently support the most advanced web techniques
  • Build an amazing social and financial application that applies microservices patterns on deployment, self-testability, interoperability, cloud architectures, and scalability
  • Fast-paced, practical guide to learn how to set up Spring MVC to produce REST resources and templates as required by the latest front-end best practices

Who This Book Is For

If you are an experienced Java developer, with prior experience in web technologies, and want to step up in your career and stay up-to-date or learn more about Spring Web scalability, this book is for you.

What You Will Learn

  • Structure your project with Maven and create self-tested, domain-specific deployable web archives
  • Generate templates for a responsive and powerful frontend with AngularJS and Bootstrap
  • Build a high performance stateless RESTful and hypermedia application to support your multiple customer experiences
  • Authenticate over REST with a BASIC authentication scheme and OAuth2; handle roles and permissions
  • Document and publish your REST API using Swagger and Swagger UI
  • Scale your Spring web application
  • Communicate through WebSocket and STOMP messages
  • Provide support to your application and efficiently maintain its business features with a relevant test stack

In Detail

Spring MVC is a lightweight application framework that comes with a great configuration by default. Being part of the Spring Framework, it naturally extended and supported it with an amazing set of recognizable annotations. External libraries can be plugged in and plugged out. It also possesses a request flow.

Complete support of REST web services makes the Spring architecture an extremely consistent choice to support your front-end needs and Internet transformations.

From the design of your Maven modules, you will achieve an Enterprise-standard for a stateless REST application based on Spring and Spring MVC with this book.

This guide is unique in its style as it features a massive overview of practical development techniques brought together from the Spring ecosystem, the new JEE standards, the JavaScript revolution and Internet of Things.

You will begin with the very first steps of Spring MVC's product design. Focused on deployment, viability, and maintainability, you will learn the use of Eclipse, Maven, and Git. You will walk through the separation of concerns driven by the microservices principles. Using Bootstrap and AngularJS, you will develop a responsive front-end, capable of interacting autonomously with a REST API.

Later in the book, you will setup the Java Persistence API (JPA) within Spring; learn how to configure your Entities to reflect your domain needs, and discover Spring Data repositories. You will analyze how Spring MVC responds to complex HTTP requests. You will implement Hypermedia and HATEOAS to guide your customer's stateless conversation with the product and see how a messaging-service based on WebSocket can be configured. Finally you will learn how to set up and organize different levels of automated-tests, including logging and monitoring.

Style and approach

A comprehensive, recipe-based guide to creating stunning Java apps with Spring MVC as a result of learning and implementing pro-level practices, techniques, and solutions.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Spring MVC Cookbook


Table of Contents

Spring MVC Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why Subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
The showcase application: CloudStreet Market
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Setup Routine for an Enterprise Spring Application
Introduction
Why such a routine?
Why making use of the Eclipse IDE?
Why making use of Maven?
What does the Spring Framework bring?
Installing Eclipse for JEE Developers and Java SE 8
Getting ready
How to do it...
How it works…
Eclipse for Java EE developers
Choosing a JVM
Java SE 8
Configuring Eclipse for Java 8, Maven 3, and Tomcat 8
Getting ready
How to do it...
How it works...
The eclipse.ini file
Setting the –vm option
Customizing JVM arguments
Changing the JDK compliance level
Configuring Maven
A repository manager
Tomcat 8 inside Eclipse
There's more...
Defining the project structure with Maven
Getting ready
How to do it...
How it works...
New Maven project, new Maven module
The standard project hierarchy
The project's structure in the IDE
Maven's build life cycles
The clean life cycle
The default life cycle
Plugin goals
Built-in life cycle bindings
About Maven commands
There's more...
How did we choose the jar module's name?
How did we choose the names for deployable modules?
Why did we create core modules?
See also...
Installing Spring, Spring MVC, and a web structure
Getting ready
How to do it...
How it works...
Inheritance of Maven dependencies
Basic inheritance
Managed inheritance
Including third-party dependencies
The Spring Framework dependency model
The Spring MVC dependency
Using Maven properties
The web resources
The target runtime environment
The Spring web application context
Plugins
The Maven compiler plugin
The Maven surefire plugin
The Maven enforcer plugin
The Maven war plugin
There's more...
See also
The Maven checkstyle plugin
2. Designing a Microservice Architecture with Spring MVC
Introduction
The User eXperience paradigm
Microservice architectures
Configuring a controller with simple URL mapping
Getting ready
How to do it...
Downloading and installing GIT
Configuring GIT in Eclipse
How it works...
Spring MVC overview
Front controller
MVC design pattern
Spring MVC flow
DispatcherServlet – the Spring MVC entrypoint
Annotation-defined controllers
@Controller
@RequestMapping
Controller method-handler signatures
Supported method arguments types
Supported annotations for method arguments
Supported return Types
There's more...
Configuring a fallback controller using ViewResolver
Getting ready
How to do it...
How it works...
URI template patterns
Ant-style path patterns
Path pattern comparison
ViewResolvers
There's more...
@PathVariable to read variables in URI template patterns
Setting up and customizing a responsive single page webdesign with Bootstrap
Getting ready
How to do it...
Installing a Bootstrap theme
Customising a Bootstrap theme
Creating responsive content
How it works...
The theme installation
Bootstrap highlights
Bootstrap scaffolding
Grid system and responsive design
Defining columns
Offsetting and nesting
Fluid gridding
Bootstrap CSS utilities
Uniform Buttons
Icons
Tables
Bootstrap components
Navbars
Hero units
Alerts
Badges and labels
There's more...
See also
Displaying a model in the View, using the JSTL
Getting ready
How to do it...
How it works...
The approach to handle our data
Injection of services via interfaces
How does Spring choose the dummy implementations?
DTOs to be used in View layer
Dummy service implementations
Populating the Model in the controller
Rendering variables with the JSP EL
Implicit objects
Rendering variables with the JSTL
Taglib directives in JSPs
There's more...
More about JSP EL
More about the JavaBeans standard
More about the JSTL
Defining a common WebContentInterceptor
Getting ready
How to do it...
How it works...
Common behaviors for Controllers
Global session control
Requiring sessions
Synchronizing sessions
Cache-header management
HTTP method support
A high-level interceptor
Request lifecycle
There is more...
More features offered by WebContentGenerator
See also...
Web caching
New support classes for @RequestMapping since Spring MVC 3.1
Designing a client-side MVC pattern with AngularJS
Getting ready
How to do it...
Setting up the DOM and creating modules
Defining the module's components
How it works...
One app per HTML document
Module autobootstrap
Manual module bootstrap
AngularJS Controllers
Bidirectional DOM-scope binding
AngularJS directives
ng-repeat
ng-if
AngularJS factories
Dependency injection
There's more...
3. Working with Java Persistence and Entities
Introduction
The Entities' benefits
Th...

Table of contents

  1. Spring MVC Cookbook

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Spring MVC Cookbook by Alex Bretet in PDF and/or ePUB format, as well as other popular books in Computer Science & Application Development. We have over one million books available in our catalogue for you to explore.