In this short video, we look at the difference between Controller and RestController.
A RestController is simply a Controller augmented with the ResponseBody annotation.
The ResponseBody says to send the result directly as the response.
If ResponseBody is not specified, the result is interpreted as the name of a view, which is simply the path to another controller in this case. If no controller is defined for this path, the result is 404, with not much additional info. But if the controller is found, it is used.
Here, we basically redirect the hello controller to the success controller, which we create. Then we redirect the success itself to yapla.
ResponseBody can be specified at the class level or at the method level.
In the end, we have three urls: /hello maps to /success, and /success maps to /yapla, and every URL can be used as an entry point.
This may seem a bit curious here, but in many scenarios, the Controller is an entry point which redirect to a JSP page or another rendering engine, so there are usually only two levels of indirection.