# Spring MVC Basics (Spring Boot) > Spring MVC, MVC-Architektur, DispatcherServlet, @Controller, ViewResolver, Model-View-Controller-Pattern - 20 Interview-Fragen - Mid-Level - [Interview-Fragen: Spring Boot](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen.md) ## 1. Welche Annotation verwandelt eine Java-Klasse in einen Spring-MVC-Controller? **Antwort** @Controller markiert eine Klasse als Spring-MVC-Controller, der HTTP-Anfragen verarbeitet. Es ist eine Spezialisierung von @Component und ermöglicht es dem Component Scanning, den Controller automatisch zu erkennen. @RestController kombiniert @Controller und @ResponseBody für REST-APIs, während @RequestMapping URL-Mappings definiert, aber selbst keinen Controller deklariert. ## 2. Was ist der Hauptunterschied zwischen @Controller und @RestController? **Antwort** @RestController kombiniert @Controller und @ResponseBody, was bedeutet, dass alle Methoden automatisch serialisierte Daten (JSON/XML) anstelle von View-Namen zurückgeben. Bei @Controller müssen Sie jeder Methode @ResponseBody hinzufügen, um Daten zurückzugeben. @RestController ist für REST-APIs konzipiert, während @Controller für traditionelle Webanwendungen mit View-Rendering verwendet wird. ## 3. Wie ordnet man eine Controller-Methode einer HTTP-POST-Anfrage auf der URL /users zu? **Antwort** @PostMapping ist die spezialisierte Annotation, um eine Methode POST-Anfragen auf einer bestimmten URL zuzuordnen. Es ist eine Kurzform für @RequestMapping(method = RequestMethod.POST). Weitere spezialisierte Annotationen sind @GetMapping, @PutMapping, @DeleteMapping und @PatchMapping. Dieser Ansatz ist lesbarer und prägnanter als @RequestMapping mit dem method-Attribut. ## 17 weitere Fragen verfügbar - Wie ruft man eine Pfadvariable aus einer URL wie /users/{id} ab? - Welche Annotation wird verwendet, um JSON aus dem HTTP-Anfragetext automatisch zu deserialisieren? Kostenlos registrieren: https://sharpskill.dev/de/login ## Weitere Spring Boot-Interviewthemen - [Spring Core - IoC & DI](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-core-ioc-di.md): 22 Fragen, Junior - [Spring Boot Auto-Configuration](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-boot-auto-configuration.md): 20 Fragen, Junior - [Spring Boot Starters](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-boot-starters.md): 18 Fragen, Junior - [Application Properties & YAML](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/application-properties-yml.md): 16 Fragen, Junior - [Logging mit SLF4J und Logback](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/logging.md): 20 Fragen, Junior - [Spring Boot DevTools](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-boot-devtools.md): 15 Fragen, Junior - [Spring REST Controllers](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-rest-controllers.md): 20 Fragen, Mid-Level - [Request & Response Handling](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/request-response-handling.md): 20 Fragen, Mid-Level - [Ausnahmebehandlung](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/exception-handling.md): 25 Fragen, Mid-Level - [Bean Validation](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/bean-validation.md): 25 Fragen, Mid-Level - [Spring Data JPA Grundlagen](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-data-jpa-basics.md): 25 Fragen, Mid-Level - [JPA-Entitäten und Beziehungen](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/jpa-entities-relationships.md): 30 Fragen, Mid-Level - [JPA-Abfragen](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/jpa-queries.md): 30 Fragen, Mid-Level - [Spring Data Repositories](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-data-repositories.md): 25 Fragen, Mid-Level - [Spring Security Grundlagen](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-security-basics.md): 25 Fragen, Mid-Level - [Spring Boot Actuator](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-boot-actuator.md): 20 Fragen, Mid-Level - [Unit-Tests mit JUnit & Mockito](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/testing-junit-mockito.md): 30 Fragen, Mid-Level - [Spring Boot Testing](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-boot-testing.md): 30 Fragen, Mid-Level - [Profiles und Environment](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/profiles-environment.md): 20 Fragen, Mid-Level - [RestTemplate und WebClient](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/resttemplate-webclient.md): 24 Fragen, Mid-Level - [Async & Scheduling](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/async-scheduling.md): 25 Fragen, Mid-Level - [Caching mit Spring](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/caching.md): 25 Fragen, Mid-Level - [Spring WebFlux (Reactive)](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-webflux.md): 25 Fragen, Mid-Level - [Spring-Transaktionen](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/transactions.md): 30 Fragen, Senior - [Erweiterte Authentifizierung und Autorisierung](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/authentication-authorization.md): 30 Fragen, Senior - [JWT & Stateless-Sicherheit](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/jwt-stateless-security.md): 20 Fragen, Senior - [OAuth2 & Authorization Server](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/oauth2-authorization-server.md): 20 Fragen, Senior - [Spring Boot und Docker](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-boot-docker.md): 19 Fragen, Senior - [Microservices mit Spring](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/microservices-basics.md): 25 Fragen, Senior - [Spring Cloud Config](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-cloud-config.md): 19 Fragen, Senior - [Performance-Optimierung](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/performance-optimization.md): 30 Fragen, Senior - [GraalVM Native Images](https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/graalvm-native-images.md): 20 Fragen, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/de/technologies/spring-boot/interviewfragen/spring-mvc-basics