Creating a RESTful web service
In our previous recipe, we interacted with data using web forms. In this recipe, we will see how to interact with data using RESTful web services. These web services are a means to interact with other applications using the known HTTP protocol and its methods, namely GET, POST, and PUT. The data can be exchanged in the form of XML, JSON, or even plain text. We will be using JSON in our recipe.Â
So, we will create RESTful APIs to support retrieving data, creating new data, editing data, and deleting data.Â
Â
Getting ready
As usual, download the starter project from http://start.spring.io/Â by selecting the dependencies shown in the following screenshot:
How to do it...
- Copy the
Person
class from the previous recipe:
public class Person { private Integer id; private String firstName; private String lastName; private String place; //required getters and setters }
- We will do the
PersonMapper
part in a different...