The @Controller annotation indicates that a particular class serves the role of a controller. Spring Controller annotation is typically used in combination with annotated handler methods based on the @RequestMapping annotation. It can be applied to classes only. It's used to mark a class as a web request handler
xxxxxxxxxx
// Annotation
@Controller
// Main class
public class DemoController {
@RequestMapping("/hello")
@ResponseBody
// Method
public String helloGFG()
{
return "Hello GeeksForGeeks";
}
}
https://www.geeksforgeeks.org/spring-controller-annotation-with-example/