Dung (Donny) Nguyen

Senior Software Engineer

Controller and RestController

In the Spring framework, @Controller and @RestController are used to define controllers, but they serve different purposes and are used in different scenarios:

@Controller

@RestController

In summary, @Controller is used for traditional web applications that return views, while @RestController is used for RESTful web services that return data directly in formats like JSON or XML.

References: