Spring MVC Flashcards

1
Q

What is Spring MVC?

A

A web framework in Spring for building web applications using the Model-View-Controller architecture.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What annotation is used to define a controller in Spring MVC?

A

@Controller.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the use of the @RequestMapping annotation?

A

It maps HTTP requests to handler methods in controllers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you return JSON data from a Spring MVC controller?

A

By using @RestController or adding @ResponseBody to methods returning JSON.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is @RestController in Spring MVC?

A

It combines @Controller and @ResponseBody for RESTful web services.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you handle form data in Spring MVC?

A

Using @ModelAttribute or @RequestParam in the controller methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between @RequestParam and @PathVariable?

A

@RequestParam extracts query parameters, while @PathVariable extracts values from the URI path.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a ViewResolver in Spring MVC?

A

A component that resolves logical view names to actual view implementations, like JSP or Thymeleaf.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you handle exceptions in Spring MVC?

A

Using @ExceptionHandler in a controller or a global exception handler with @ControllerAdvice.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the DispatcherServlet in Spring MVC?

A

The front controller in Spring MVC that handles all incoming web requests and delegates them to the appropriate controllers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly