Spring różnica pomiędzy @Controller a @RestController

0

Tak jak w temacie. Czym różnią się te adnotacje?

1

Proszę bardzo:
https://www.baeldung.com/spring-controller-vs-restcontroller

A tutaj z dokumentacji:

public @interface RestController
A convenience annotation that is itself annotated with @Controller and @ResponseBody.
Types that carry this annotation are treated as controllers where @RequestMapping methods assume @ResponseBody semantics by default.
0
Tyvrel napisał(a):

Proszę bardzo:
https://www.baeldung.com/spring-controller-vs-restcontroller

A tutaj z dokumentacji:

public @interface RestController
A convenience annotation that is itself annotated with @Controller and @ResponseBody.
Types that carry this annotation are treated as controllers where @RequestMapping methods assume @ResponseBody semantics by default.

brawo kopiować umiesz, chciałbym bardziej swoimi słowami jak i kiedy tego używać zamist @Controller

1

RestController to jest Controller który zwraca dane zamiast całych widoków. Można to samo osiągnąć dodając sobie adnotacje ResponseBody do Controllera.

1 użytkowników online, w tym zalogowanych: 0, gości: 1