Showing posts with the label @RestController

Spring @RestController Annotation Example

In this section we will learn about  @RestController  Annotation.   The  @RestController   annotation is mainly utilized for building restful web services utilizing Spring MVC. It is a convenience annotation, this annotation itself annotated with @ResponseBody and @Controller annotation. The class annotated with @RestController annotation returns JSON replication in all the methods. @RestController public class UserController { @GetMapping ( "/users" ) public User getUser ( ) { //TODO } } The following example creates a Spring Boot web application which uses @RestController .  Project Directory Pom.xml <? xml version ="1.0" encoding ="UTF-8" ?> < project xmlns ="" xmlns: xsi ="" xsi :schemaLocation ="" > < modelVersion &g