1
votes

While migrating from Spring 3.x to 5.1.15, found that AnnotationMethodHandlerAdapter is being deprecated. Upon research with stack flow articles, it was suggested to use RequestMappingHandlerAdapter and RequestMappingHandlerMapping and <mvc:annotation-driven /> in the servlet.xml. But it is not fixing the issue, still facing the same issue - Dispatcher servlet configuration needs to include a HandlerAdapter that supports this handler. Any help is really appreciated!!

1

1 Answers

-1
votes

I think, something wrong with your configuration, because I cannot view your code. I suggest to use something like this with Spring MVC:

@Controller
public class EmployeeController {
    @GetMapping("/employee")
    public ModelAndView getEmployeeName() {
        ModelAndView model = new ModelAndView("Greeting");        
        model.addObject("message", "Dinesh");       
        return model;  
    }  
}

Where:

  1. @Controller - marks your class as a Servlet that handles requests.
  2. @GetMapping enables to accept GET requests by your controller for path /employee
  3. ModelAndView - this is a class that contains requests attributes and path to HTML/JSP/other page, preconfigured in your application
  4. model.addObject("message", "Dinesh") adds attribute to your (in this case) Thymeleaf page. You can annotate your class and methods with other Spring MVC features as described here, I didn't provide any other configs

It's now more preferable way to use annotated beans instead XML beans, but BTW depends on preferences.

Best Regards, Anton.