...

/

Develop the REST Controllers

Develop the REST Controllers

Let’s learn to use annotations like `@RestController` and `@RequestMapping` to expose the REST APIs.

Create REST controller

Create the TodoTypeController class in the io.educative.controllers package to work as a REST controller.

Press + to interact
package io.educative.controllers;
import org.springframework.web.bind.annotation.*;
@RestController //define TodoTypeController as REST controller
@RequestMapping("/api/todoType") //expose the REST endpoints at /api/todoType
public class TodoTypeController {
}

In the above code section, we see the following annotations that help expose the REST APIs:

  • The @RestController annotation combines the @Controller and @ResponseBody
...