Wednesday, 28 February 2018

Spring web service one

Spring MVC Framework and REST

1.Spring MVC :-Client request to Dispatcher-->handler mapping-->Controller-->view

2.REST spring  :-client request to web service in URI form--->intercepted by Dispatcher it find the controller based on incoming request -->request proced by controller and responds is return to the dispatcher which then dispatched to view

Using the @ResponseBody Annotation

When you use the @ResponseBody annotation on a method, Spring converts the return value and writes it to the http response automatically. Each method in the Controller class must be annotated with @ResponseBody.

##Using the @RestController Annotation

   Spring 4.0 introduced @RestController

    By annotating the controller class with @RestController annotation, you no longer need to add @ResponseBody to all the request mapping methods. The @ResponseBody annotation is active by default

No comments:

Post a Comment