Return to site

🍃🎓 SPRING CERTIFICATION QUESTION: HandlerAdapter & HandlerMapping

· spring,java,vcp

Which is true about the workflow of mapping an incoming request to a controller method? Choose two.

(A handler method is a method annotated with @RequestMapping/@GetMapping/@PostMapping/... inside a controller class annotated with @Controller/@RestController).

* Incoming requests are mapped to a controller handler method by the DispatcherServlet

* HandlerAdapter defines a strategy for mapping client requests to controllers.

* HandlerMapping handles HTTP requests by invoking the appropriate controller method.

* DispatcherServlet uses components of type HandlerAdapter and HandlerMapping

#spring #certificationquestion #vcp

https://www.udemy.com/course/spring-professional-certification-6-full-tests-2v0-7222-a/?referralCode=04B6ED315B27753236AC

Right answers:

Incoming requests are mapped to a controller handler method by the DispatcherServlet.

This is true. The DispatcherServlet is the front controller in Spring MVC and is responsible for handling incoming requests.

It uses various components, including HandlerMapping, to determine which controller method (handler method) should handle the request.

DispatcherServlet uses components of type HandlerAdapter and HandlerMapping.

This is true.

DispatcherServlet relies on HandlerAdapter to invoke the appropriate controller method and HandlerMapping to map the request to the correct handler.

Wrong answers:

HandlerAdapter defines a strategy for mapping client requests to controllers.

This statement is false.

HandlerAdapter is responsible for adapting (invoking) the controller method to handle a request, but it does not define the strategy for mapping requests to controllers.

The mapping strategy is the role of HandlerMapping.

HandlerMapping handles HTTP requests by invoking the appropriate controller method.

This statement is false.

HandlerMapping is responsible for determining which controller method (handler method) should handle a specific request by mapping the request to the appropriate handler.

However, HandlerMapping itself does not handle the request; it provides the mapping information to the DispatcherServlet.

The actual handling of the request is done by HandlerAdapter, which is responsible for adapting the request to the controller method.