RESTFul Web Services
RESTFul API can be implemented using
RestController is created by @RestController
JSON objects are returned by REST Controllers
Q: How do you create RestFul web services?
A: Using rest controllers.
Q: Which data is returned by RestFul web services?
A: JSON data.
Q: What are the differences between Normal and Rest controllers?
A: Rest controllers always return response in JSON format whereas normal controllers may return response into XML, HTML, tiles of any other format.
Q: What are the differences between SOAP and Restful services?
A: Rest controllers always return response in JSON format whereas SOAP return XML.
Q: How do you test restful controllers
A: Using POSTMAN
Q: How do map request JSON object to a Form bean?
A: We use @RequestBody annotation
Q: What is the function of @RequestBody annotation
A: It maps JSON data from the request body to Java bean. Or It reads JSON object from the POST request and stores into java bean
Q: What is the function of @ResponseBody annotation?
A: It converts Java bean into JSON object and sends it to the Response body. Or it converts JavaBean into JSON object and write to the response