In this chapter of Mastering Spring MVC 4, we’ll tackle main principles of a RESTful architecture. We’ll learn how to convert data to JSON and handle different media types in the application.

We will use the JSR-310 (Java DateTime) spec from the get-go and see how to handle them properly in your MVC application.

Forever RESTful

We will see how REST works in theory: HTTP codes and verbs, API versioning, HATEOAS, etc.

Then, we will design an API that uses both JSON and XML to do a twitter search and manage users.



I will also show you some useful tools to debug REST API. My favorite one is a little command line tool called httpie.

You will study the best practice like exceptions handling and custom error pages.

We will also see how to set up Jackson serialization using mixins and Java 8 dates.


We will use swagger to document our API.

I hope you will find the content of this chapter interesting, let me know your thoughts in the comments!