万本电子书0元读

万本电子书0元读

顶部广告

Spring MVC: Designing Real-World Web Applications电子书

售       价:¥

7人正在读 | 0人评论 9.8

作       者:Shameer Kunjumohamed

出  版  社:Packt Publishing

出版时间:2016-11-01

字       数:1501.3万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
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.
目录展开

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

What this learning path covers

What you need for this learning path

Who this learning path is for

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

I. Module 1

1. Getting Started with Spring Core

The Spring landscape

The Spring Framework modules

Spring Tool Suite (STS)

Spring subprojects

Design concepts behind Spring Framework

Setting up the development environment

Your first Spring application

Inversion of Control explained

Dependency Injection

The Spring IoC container

Configuration metadata

XML-based configuration metadata

Annotation-based configuration metadata

XML-based versus annotation-based configuration

Component stereotype annotations

Java-based configuration metadata

JSR 330 standard annotations

Beans in detail

Bean definition

Instantiating beans

With constructors

With a static factory-method

With an instance factory-method

Injecting bean dependencies

Constructor-based Dependency Injection

Setter-based Dependency Injection

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

Implementing InitializingBean and DisposableBean

Annotating @PostConstruct and @PreDestroy on @Components

The init-method and destroy-method attributes of <bean/>

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

SpEL features

SpEL annotation support

The SpEL API

Aspect Oriented Programming

Static and dynamic AOP

AOP concepts and terminology

Spring AOP – definition and configuration styles

XML schema-based AOP

@AspectJ annotation-based AOP

Declaring an @Aspect annotation

Pointcuts

Pointcut designators

Pointcut examples

Advices

The @Around Advice

Accessing Advice parameters

Testing with Spring

Mock objects

Unit and integration testing utilities

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 project structure of a Spring MVC application

The web.xml file – Springifying the web app

ApplicationContext files in a Spring MVC application

HomeController – @Controller for the home screen

The home.jsp file – the landing screen

Handling incoming requests

The architecture and components of Spring MVC

DispatcherServlet explained

WebApplicationContext – ApplicationContext for the Web

Beans supporting DispatcherServlet and their roles

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

Resolving views

Resolving JSP views

Binding Model attributes in JSP pages using JSTL

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

JdbcTemplate

NamedParameterJdbcTemplate

SimpleJdbc classes

JDBC operations with Sql* classes

Spring Data

Spring Data Commons

Spring Data repository specification

Spring Data JPA

Enabling Spring Data JPA

JpaRepository

Spring Data MongoDB

Enabling Spring Data MongoDB

MongoRepository

Domain objects and entities

Query resolution methods

Using the @Query annotation

Spring Data web support extensions

Auditing with Spring Data

Spring Transaction support

Relevance of Spring Transaction

Spring Transaction fundamentals

Declarative transaction management

Transactional modes – proxy and AspectJ

Defining transactional behavior

Setting rollback rules

Using the @Transactional annotation

Enabling transaction management for @Transactional

Programmatic transaction management

Summary

4. Understanding WebSocket

Creating a simple WebSocket application

STOMP over WebSocket and the fallback option in Spring 4

Broadcasting a message to a single user in a WebSocket application

Summary

5. Securing Your Applications

Authentication

Authorization

The OAuth2 Authorization Framework

Summary

6. Building a Single-Page Spring Application

The motivations behind SPAs

SPAs explained

The architectural benefits of SPAs

SPA frameworks

Introducing Ember.js

The anatomy of an Ember application

Routers

Routes or route handlers

Templates

Components

Models

Controllers

Input helpers

Custom helpers

Initializers

Services

Working with Ember CLI

Setting up Ember CLI

Getting started with Ember CLI commands

The Ember project structure

Working with the POD structure

Understanding the Ember object model

Declaring types (classes) and instances

Accessing and mutating properties

Computed properties

Property observers

Working with collections

Building UI templates using Handlebars

Handlebars helpers

Data binding with input helpers

Using control flow helpers in Handlebars

Using event helpers

Handling routes

Handling UI behavior using components

Building a ToggleButton component step by step

Persisting data with Ember Data

Ember Data architecture

Defining models

Defining model relationships

Building a Taskify application

Building the API server app

Setting up and configuring the project

Defining the model definitions – User and Task

Building API endpoints for the Taskify app

UserController.java

TaskController.java

Building the Taskify Ember app

Setting up Taskify as an Ember CLI project

Setting up Ember Data

Configuring application routes

Building the home screen

Building the user screen

Building a custom helper

Adding action handlers

Building a custom component – modal window

Building userEditModal using {{modal-window}}

Building the task screen

Summary

7. Integrating with Other Web Frameworks

Spring's JSF integration

Spring's Struts integration

Summary

II. Module 2

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

The Entity manager and its persistence context

Configuring the Java Persistence API in Spring

Getting ready

How to do it...

How it works...

The Spring-managed DataSource bean

The EntityManagerFactory bean and its persistence unit

The Spring Data JPA configuration

See also

Defining useful EJB3 entities and relationships

Getting ready

How to do it...

How it works...

Entity requirements

Mapping the schema

Mapping tables

Mapping columns

Annotating fields or getters

Mapping primary keys

Identifier generation

Defining inheritance

The single-table strategy

The table-per-class strategy

Defining relationships

How relationships between entities have been chosen

There's more...

The FetchType attribute

The Cascade attribute

See also

Making use of the JPA and Spring Data JPA

How to do it...

How it works...

Injecting an EntityManager instance

Using JPQL

Reducing boilerplate code with Spring Data JPA

Query creation

Persisting Entities

There's more...

Using native SQL queries

Transactions

See also

4. Building a REST API for a Stateless Architecture

Introduction

A definition of REST

RESTful CloudStreetMarket

Binding requests and marshalling responses

Getting ready

How to do it...

How it works...

A super RequestMappingHandlerAdapter bean

Broad support for @RequestMapping annotations

setMessageConverters

setCustomArgumentResolvers

setWebBindingInitializer

The ConversionService API

Choosing between PropertyEditors or converters

There's more...

Built-in PropertyEditor implementations

The Spring IO reference document

Configuring content-negotiation (JSON, XML, and so on)

Getting ready

How to do it...

How it works...

Support for XML marshalling

The XStream marshaller

Negotiation strategies with ContentNegotiationManager

The Accept header

The file extension suffix in the URL path

The request parameter

Java Activation Framework

@RequestMapping annotations as ultimate filters

There's more...

Using a JAXB2 implementation as an XML parser

The ContentNegotiationManagerFactoryBean JavaDoc

Adding pagination, filters, and sorting capabilities

Getting ready

How to do it...

How it works...

Spring Data pagination support (you will love it!)

Pagination and sorting in repositories

PagingAndSortingRepository<T,ID>

The web part – PageableHandlerMethodArgumentResolver

A useful specification argument resolver

The JPA2 criteria API and Spring Data JPA specifications

SpecificationArgumentResolver

There's more...

Spring Data

Angular routes

See also

Bootstrap pagination with the Angular UI

Handling exceptions globally

Getting ready

How to do it...

How it works...

Global exception handling with @ControllerAdvice

The support ResponseEntityExceptionHandler class

A uniform error response object

There's more...

HTTP Status Codes

The official article about exception handling in Spring MVC

JavaDocs

See also

Documenting and exposing an API with Swagger

Getting ready

How to do it...

How it works...

An exposed metadata

The Swagger UI

There's more...

The Swagger.io

The swagger-springmvc documentation

See also

Different tools, different standards

5. Authenticating with Spring MVC

Introduction

Configuring Apache HTTP to proxy your Tomcat(s)

Getting ready

How to do it...

How it works...

DNS configuration or host aliasing

In production – editing DNS records

An alias for the host

Alias definition for OAuth developments

Apache HTTP configuration

Virtual-hosting

The mod_proxy module

ProxyPassReverse

Workers

The mod_alias module

Tomcat connectors

HTTP connectors

AJP connectors

There is more…

See also

Alternatives to Apache HTTP

Adapting users and roles to Spring Security

Getting ready

How to do it...

How it works...

Introduction to Spring Security

ThreadLocal context holders

Noticeable Spring Security interfaces

The Authentication interface

The UserDetails interface

Authentication providers

The UserDetailsManager interface

The GrantedAuthority interface

There is more…

Spring Security reference

Technical overview

Sample applications

Core services

Authenticating over a BASIC scheme

Getting ready

How to do it...

How it works...

The Spring Security namespace

The <http> component

The Spring Security filter-chain

Our <http> configuration

The AuthenticationManager interface

Basic authentication

BasicAuthenticationFilter

With an authenticationEntryPoint

Without an authenticationEntryPoint

There is more…

In the Spring Security reference

The remember-me cookie/feature

Authenticating with a third-party OAuth2 scheme

Getting ready

How to do it...

How it works...

From the application point of view

From the Yahoo! point of view

OAuth2 explicit grant flow

Refresh-token and access-token

Spring social – role and key features

Social connection persistence

Provider-specific configuration

One entry-point – connectionFactoryLocator

Provider-specific ConnectionFactories

Signing in with provider accounts

There is more…

Performing authenticated API calls

The Spring social ConnectController

See also

SocialAuthenticationFilter

The list of Spring social connectors

Implementing an OAuth2 authentication server

The harmonic development blog

Storing credentials in a REST environment

Getting ready

How to do it...

Client side (AngularJS)

Server side

How it works...

Authenticating for Microservices

Using the BASIC authentication

Using OAuth2

HTML5 SessionStorage

SSL/TLS

BCryptPasswordEncoder

There is more…

Setting HTTP headers with AngularJS

Browser support for localStorage

About SSL and TLS

Authorizing on services and controllers

Getting ready

How to do it...

How it works...

Spring Security authorities

Configuration attributes

Pre-invocation handling

AccessDecisionManager

After invocation handling

Expression-based access control

Web Security expressions

Method security expressions

Access control using @PreAuthorize and @PostAuthorize

Filtering collections using @PreFilter and @PostFilter

JSR-250 and legacy method security

There is more…

Domain Object Security (ACLs)

Spring EL

The Spring Security reference

See also

6. Implementing HATEOAS

Introduction

The Richardson Maturity Model

Turning DTOs into Spring HATEOAS resources

How to do it…

How it works...

Spring HATEOAS resources

The ResourceSupport class

The Resource class

The Identifiable interface

Abstracting the Entities' @Id

There's more…

See also

Building links for a hypermedia-driven API

How to do it…

How it works...

Resource assemblers

PagedResourcesAssembler

Building links

EntityLinks

ControllerLinkBuilder

There's more…

The use of regular expressions in @RequestMapping

See also

Choosing a strategy to expose JPA Entities

How to do it…

How it works...

The REST CRUD principle

Exposing the minimum

If the Entity doesn't own the relationship

If the Entity owns the relationship

Separation of resources

There's more…

Jackson custom serializers

XStream converters

Retrieving data from a third-party API with OAuth

How to do it…

How it works...

Introduction to the financial data of Yahoo!

Graph generation/display

How is the financial data pulled/refreshed?

Calling third-party services

There's more…

Spring Social — existing API providers

See also

7. Developing CRUD Operations and Validations

Introduction

Extending REST handlers to all HTTP methods

Getting ready

How to do it…

How it works...

HTTP/1.1 specifications – RFC 7231 semantics and content

Basic requirements

Safe and Idempotent methods

Other method-specific constraints

Mapping request payloads with @RequestBody

HttpMessageConverters

Provided HttpMessageConverters

Using MappingJackson2HttpMessageConverter

Using @RequestPart to upload an image

Transaction management

The simplistic approach

There's more…

Transaction management

ACID properties

Global versus local transactions

See also

Validating resources using bean validation support

Getting ready

How to do it…

How it works...

Using Spring validator

ValidationUtils

I18n validation errors

Using JSR-303/JSR-349 Bean Validation

On-field constraint annotations

Implementation-specific constraints

LocalValidator (reusable)

There's more…

ValidationUtils

Grouping constraints

Creating a custom validator

The Spring reference on validation

See also

Internationalizing messages and contents for REST

How to do it…

Backend

Frontend

How it works...

MessageSource beans

ResourceBundleMessageSource

ReloadableResourceBundleMessageSource

StaticMessageSource

Our MessageSource bean definition

Using a LocaleResolver

AcceptHeaderLocaleResolver

FixedLocaleResolver

SessionLocaleResolver

CookieLocaleResolver

There's more…

Translating client-side with angular-translate.js

Validating client-side forms with HTML5 AngularJS

How to do it…

How it works...

Validation-constraints

Required

Minimum/maximum length

Regex pattern

Number/e-mail/URL

Control variables in forms

Modified/Unmodified state

Valid/Invalid state

Errors

Form state transclusions and style

See also

8. Communicating Through WebSockets and STOMP

Introduction

Streaming social events with STOMP over SockJS

Getting ready

How to do it…

Apache HTTP Proxy configuration

Frontend

Backend

How it works...

An introduction to WebSockets

WebSocket Lifecycle

Two dedicated URI schemes

The STOMP protocol

SockJS

Spring WebSocket support

All-in-one configuration

Defining message handlers via @MessageMapping

Sending a message to dispatch

SimpMessagingTemplate

The @SendTo annotation

There's more…

See also

Using RabbitMQ as a multiprotocol message broker

Getting ready

How to do it…

How it works...

Using a full-featured message broker

Clusterability – RabbitMQ

More STOMP message types

StompMessageBrokerRelay

See also

Stacking and consuming tasks with RabbitMQ and AMQP

Getting ready

How to do it…

Sender side

Consumer side

Client-side

How it works...

Messaging architecture overview

A scalable model

AMQP or JMS?

There's more…

A great introduction to AMQP by pivotal

A better way to publish application events

See also

Securing messages with Spring Session and Redis

Getting ready

How to do it…

Apache HTTP proxy configuration

Redis server installation

MySQL server installation

Application-level changes

RabbitMQ configuration

The results

How it works...

The Redis server

Spring session

SessionRepositoryFilter

RedisConnectionFactory

CookieHttpSessionStrategy

Spring Data Redis and Spring Session Data Redis

The Redis Session manager for Tomcat

Viewing/flushing sessions in Redis

securityContextPersistenceFilter

AbstractSessionWebSocketMessageBrokerConfigurer

AbstractSecurityWebSocketMessageBrokerConfigurer

There's more…

Spring Session

Apache HTTP proxy extra configuration

Spring Data Redis

See also

9. Testing and Troubleshooting

Introduction

Automating Database Migrations with FlyWay

Getting ready

How to do it…

How it works...

A limited number of commands

Migrate

Clean

Info

Validate

Baseline

Repair

About Flyway Maven plugin

There is more…

The official documentation

See also

Unit testing with Mockito and Maven Surefire

How to do it…

How it works...

@Test annotation

The expected and timeout arguments

The @RunWith annotation

@Before and @After annotations

@BeforeClass and @AfterClass annotations

Using Mockito

MockitoJUnitRunner

The transferCriticalData example

The registerUser example

There is more…

About Mockito

JUnit Rules

See also

Integration testing with Cargo, Rest-assured, and Maven failsafe

Getting ready

How to do it…

How it works...

Maven Failsafe versus Maven Surefire

Code Cargo

Cargo Maven Plugin

Binding to Maven phases

Using an existing Tomcat instance

Rest assured

Static imports

A Given, When, Then approach

There is more…

About Cargo

More REST-assured examples

Injecting Spring Beans into integration tests

Getting ready

How to do it…

How it works...

SpringJUnit4ClassRunner

The @ContextConfiguration annotation

There is more…

JdbcTemplate

Abstraction of boilerplate logic

Extraction of auto-generated IDs

Modern application Logging with Log4j2

Getting ready

How to do it…

How it works...

Apache Log4j2 among other logging frameworks

The case of SLF4j

Migrating to log4j 2

Log4j 2 API and Core

Log4j 2 Adapters

Log4j 1.x API Bridge

Apache Commons Logging Bridge

SLF4J Bridge

Java Util Logging Adapters

Web Servlet Support

Configuration files

There is more…

Automatic configuration

Official documentation

Interesting Redis Appender implementation

III. Module 3

1. Mastering the MVC Architecture

The MVC architecture

MVC critics and best practices

Anemic Domain Model

Learning from the sources

Spring MVC 1-0-1

Using Thymeleaf

Our first page

Spring MVC architecture

DispatcherServlet

Passing data to the view

Spring Expression Language

Getting data with a request parameter

Enough Hello Worlds, let's fetch tweets!

Registering your application

Setting up Spring Social Twitter

Accessing Twitter

Java 8 streams and lambdas

Material design with WebJars

Using layouts

Navigation

The check point

Summary

2. Handling Forms and Complex URL Mapping

The profile page – a form

Validation

Customize validation messages

Custom annotation for validation

Internationalization

Changing the locale

Translating the application text

A list in a form

Client validation

The check point

Summary

3. File Upload and Error Handling

Uploading a file

Writing an image to the response

Managing upload properties

Displaying the uploaded picture

Handling file upload errors

Translating the error messages

Placing the profile in a session

Custom error pages

URL mapping with matrix variables

Putting it together

The check point

Summary

4. Crafting a RESTful Application

What is REST?

Richardson's maturity model

Level 0 – HTTP

Level 1 – Resources

Level 2 – HTTP verbs

Level 3 – Hypermedia controls

API versioning

Useful HTTP codes

Client is the king

Debugging a RESTful API

A JSON formatting extension

A RESTful client in your browser

httpie

Customizing the JSON output

A user management API

Status codes and exception handling

Status code with ResponseEntity

Status codes with exceptions

Documentation with Swagger

Generating XML

The check point

Summary

5. Securing Your Application

Basic authentication

Authorized users

Authorized URLs

Thymeleaf security tags

The login form

Twitter authentication

Setting up social authentication

Explanation

Distributed sessions

SSL

Generating a self-signed certificate

The easy way

The dual way

Behind a secured server

The check point

Summary

6. Leaving Nothing to Luck – Unit Tests and Acceptance Tests

Why should I test my code?

How should I test my code?

Test-driven development

The unit tests

The right tools for the job

The acceptance tests

Our first unit test

Mocks and stubs

Mocking with Mockito

Stubbing our beans while testing

Should I use mocks or stubs?

Unit testing REST controllers

Testing the authentication

Writing acceptance tests

The Gradle configuration

Our first FluentLenium test

Page Objects with FluentLenium

Making our tests more Groovy

Unit tests with Spock

Integration tests with Geb

Page Objects with Geb

The check point

Summary

7. Optimizing Your Requests

A production profile

Gzipping

Cache control

Application cache

Cache invalidation

Distributed cache

Async methods

ETags

WebSockets

The check point

Summary

8. Deploying Your Web Application to the Cloud

Choosing your host

Cloud Foundry

OpenShift

Heroku

Deploying your web application to Pivotal Web Services

Installing the Cloud Foundry CLI tools

Assembling the application

Activating Redis

Deploying your web application on Heroku

Installing the tools

Setting up the application

Gradle

Procfile

A Heroku profile

Running your application

Activating Redis

Improving your application

Summary

9. Beyond Spring Web

The Spring ecosystem

Core

Execution

Data

Other noteworthy projects

The deployment

Docker

Single Page Applications

The players

The future

Going stateless

Summary

A. Bibliography

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部