# Spring MVC Basics (Spring Boot) > Spring MVC, architektura MVC, DispatcherServlet, @Controller, ViewResolver, wzorzec Model-View-Controller - 20 pytań z rozmów - Mid-Level - [Pytania z rozmów: Spring Boot](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne.md) ## 1. Która adnotacja przekształca klasę Java w kontroler Spring MVC? **Odpowiedź** @Controller oznacza klasę jako kontroler Spring MVC obsługujący żądania HTTP. Jest to specjalizacja @Component i pozwala component scanningowi automatycznie wykrywać kontroler. @RestController łączy @Controller i @ResponseBody dla API REST, natomiast @RequestMapping definiuje mapowania URL, ale samodzielnie nie deklaruje kontrolera. ## 2. Jaka jest główna różnica między @Controller a @RestController? **Odpowiedź** @RestController łączy @Controller i @ResponseBody, co oznacza, że wszystkie metody automatycznie zwracają zserializowane dane (JSON/XML) zamiast nazw widoków. W przypadku @Controller należy dodać @ResponseBody do każdej metody, aby zwrócić dane. @RestController jest przeznaczony dla API REST, natomiast @Controller jest używany w tradycyjnych aplikacjach webowych z renderowaniem widoków. ## 3. Jak zmapować metodę kontrolera do żądania HTTP POST na adresie URL /users? **Odpowiedź** @PostMapping to wyspecjalizowana adnotacja do mapowania metody na żądania POST pod określonym adresem URL. Jest skrótem dla @RequestMapping(method = RequestMethod.POST). Inne wyspecjalizowane adnotacje to @GetMapping, @PutMapping, @DeleteMapping i @PatchMapping. To podejście jest bardziej czytelne i zwięzłe niż @RequestMapping z atrybutem method. ## Jeszcze 17 dostępnych pytań - Jak pobrać zmienną ścieżki z adresu URL takiego jak /users/{id}? - Której adnotacji użyć do automatycznej deserializacji JSON z treści żądania HTTP? Zarejestruj się za darmo: https://sharpskill.dev/pl/login ## Inne tematy rekrutacyjne Spring Boot - [Spring Core - IoC & DI](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-core-ioc-di.md): 22 pytań, Junior - [Spring Boot Auto-Configuration](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-boot-auto-configuration.md): 20 pytań, Junior - [Spring Boot Starters](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-boot-starters.md): 18 pytań, Junior - [Application Properties & YAML](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/application-properties-yml.md): 16 pytań, Junior - [Logowanie z SLF4J i Logback](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/logging.md): 20 pytań, Junior - [Spring Boot DevTools](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-boot-devtools.md): 15 pytań, Junior - [Spring REST Controllers](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-rest-controllers.md): 20 pytań, Mid-Level - [Request & Response Handling](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/request-response-handling.md): 20 pytań, Mid-Level - [Obsługa wyjątków](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/exception-handling.md): 25 pytań, Mid-Level - [Bean Validation](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/bean-validation.md): 25 pytań, Mid-Level - [Podstawy Spring Data JPA](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-data-jpa-basics.md): 25 pytań, Mid-Level - [Encje JPA i relacje](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/jpa-entities-relationships.md): 30 pytań, Mid-Level - [Zapytania JPA](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/jpa-queries.md): 30 pytań, Mid-Level - [Spring Data Repositories](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-data-repositories.md): 25 pytań, Mid-Level - [Podstawy Spring Security](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-security-basics.md): 25 pytań, Mid-Level - [Spring Boot Actuator](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-boot-actuator.md): 20 pytań, Mid-Level - [Testy jednostkowe z JUnit i Mockito](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/testing-junit-mockito.md): 30 pytań, Mid-Level - [Testowanie Spring Boot](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-boot-testing.md): 30 pytań, Mid-Level - [Profiles i Environment](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/profiles-environment.md): 20 pytań, Mid-Level - [RestTemplate i WebClient](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/resttemplate-webclient.md): 24 pytań, Mid-Level - [Async i Scheduling](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/async-scheduling.md): 25 pytań, Mid-Level - [Caching ze Spring](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/caching.md): 25 pytań, Mid-Level - [Spring WebFlux (Reactive)](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-webflux.md): 25 pytań, Mid-Level - [Transakcje Spring](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/transactions.md): 30 pytań, Senior - [Zaawansowane uwierzytelnianie i autoryzacja](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/authentication-authorization.md): 30 pytań, Senior - [JWT i bezpieczeństwo stateless](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/jwt-stateless-security.md): 20 pytań, Senior - [OAuth2 i Authorization Server](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/oauth2-authorization-server.md): 20 pytań, Senior - [Spring Boot i Docker](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-boot-docker.md): 19 pytań, Senior - [Microservices ze Spring](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/microservices-basics.md): 25 pytań, Senior - [Spring Cloud Config](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-cloud-config.md): 19 pytań, Senior - [Optymalizacja wydajności](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/performance-optimization.md): 30 pytań, Senior - [GraalVM Native Images](https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/graalvm-native-images.md): 20 pytań, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/pl/technologies/spring-boot/pytania-rekrutacyjne/spring-mvc-basics