Spring RESTful Web Services – Brief Summary

Connect with

Don’t you want to focus more on bulding application rather than creating infrastructure for your code?

Here is the part where Spring plays a very significant role. It is a Java EE framework which gives you the freedom to utilize your time efficiently.

Since we are going to focus more on Spring RESTful Web Services, you can go through the link for Spring related examples.

What is Spring RESTful Web Service?

It is a combination of REST and Spring MVC framework. Spring has simplified the process of building  RESTful web services. We can say that this is the updated version of traditional Spring MVC having the difference of how the HTTP response body is created.

Difference between Spring Web Service and Spring RESTful Web Service?

Spring web services rely on View  technology while RESTful web service controller returns the object and the object data is written directly to the HTTP response as JSON/XML.

traditional workflow of Spring MVC –

  1. The client sends Request to web Service using URI form.
  2. Request reach to DispatcherServlet which search for appropriate handler mapping and it’s type.
  3.  The request is processed by Controller and response is sent back to DispatcherServlet which then dispatches it to view.

Workflow of Spring MVC RESTful web services –

  1. The client sends Request to web Service using URI form.
  2. Request reach to DispatcherServlet which search for appropriate handler mapping and it’s type.
  3.  The request is processed by Controller and via @ResponseBody response is returned to the client.

What is happening behind the scene ?

In Spring 3.x  version, when we use @ResponseBody annotation on a method, Spring write the returned value automatically in http response. Condition is, all the method must be annotated with @ResponseBody.

These all activities are handled by a list of HttpMessageConverters registered with Spring RESTWeb Service, Which convert the request body to the specific class and depending upon MIME type return response body.

Beginning with Version 4.0, this process is simplified even further with the introduction of the @RestController annotation. Using this, we don’t need to use @ResponseBody annotation with each method of the controller. It is actually a combination of @Controller and @ResponseBody annotations.

You can go through following links for better understanding of Spring RESTful Web Services-

You can write comments to improve this post. Happy Learning 🙂


Connect with

Leave a Reply

Your email address will not be published. Required fields are marked *