1.

What are the uses of @RequestMapping and @RestController annotations in Spring Boot?

Answer»
  • @RequestMapping:
    • This provides the routing information and informs Spring that any HTTP request matching the URL must be mapped to the RESPECTIVE method.
    • org.springframework.web.bind.ANNOTATION.RequestMapping has to be imported to use this annotation.
  • @RestController:
    • This is applied to a class to mark it as a request handler thereby creating RESTful web SERVICES using Spring MVC. This annotation ADDS the @ResponseBody and @Controller annotation to the class.
    • org.springframework.web.bind.annotation.RestController has to be imported to use this annotation.

Check out more Interview Questions on Spring Boot here.



Discussion

No Comment Found