HandlerAdapters in Spring MVC
HandlerMapping links a method with a URL for the DispatcherServlet to decide which method should be invoked by a certain request. The DispatcherServlet then invokes the operation using a HandlerAdapter.It is utilized in combination with HandlerMapping, which associates a certain URL with a method. Here is an example of HandlerAdapters in Spring MVC.
Java
public interface HandlerAdapter { //Check if controller is supported boolean supports(Object handler); ModelAndView handle(HttpServletRequest rqst, HttpServletResponse rsp, Object handler) throws Exception; //your implementation } |
Maven Dependency:
We need to add the below maven dependency to the XML file.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.8.RELEASE</version>
</dependency>
HandlerAdapters in Spring MVC
HandlerAdapter is in charge of actually invoking the handler. Since the handler is of type Object, any Handler type may be handled by the dispatcher servlet with the use of the HandlerAdapter. particular handler interfaces can be handled by particular HandlerAdapters that Spring offers.