Answer the question
In order to leave comments, you need to log in
RestController or Controller?
As I understand it, RestController is designed to return data in JSON format, and in Controller data is added to Model. then they return a View on which you can already pull out this data through the Model.
The essence of the question is - how to understand when to use which Controller?
Rather, the problem is that I don’t understand how then to draw the data on the View if we betray it via json ...
If someone can explain, I will be immensely grateful!)
Thank you for your attention!)
Answer the question
In order to leave comments, you need to log in
@RestController is @Controller + @ResponseBody - useful if you just need to return an object, and then Spring will deal with serialization, headers and response status (usually used when writing a REST API).
@Controller - if you need to return a ResponseEntity (useful for flexible customization of statuses and response headers), SpringMVC objects or servlet objects.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question