In this post I will show "Spring way" to build RESTful web services. It also explained how to produce multiple representations (JSON, XML and etc.), which is an important feature for RESTful web services.
This article explains another way to produce multiple representations using HttpMessageConverter, and examples in the article show how to use RestTemplate with HttpMessageConverter to communicate with services.
HTTP requests and responses are text based, meaning a browser and server communicate by exchanging raw texts. With Spring, however, methods in the controller class return pure 'String' type and domain models (or other Java built-in objects). How can Spring serialize/de-serialize the objects to raw texts? This is handled by HttpMessageConverter. Spring has bundled implementations that can meet your common needs. Table 1 shows some examples.