No adapter for handler : The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
Asked Answered
L

5

6

We are migrating from spring 4.x to spring 5.2.13 version. In spring 4 this was working but in spring 5.x we are getting the below error for dispatcher servlet

javax.servlet.ServletException: No adapter for handler : The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler at

Can anyone help me , what i am missing here? I am migrating from spring 4.x to spring 5.2.13

Lumbard answered 5/5, 2021 at 12:12 Comment(2)
what about formatting your question to make it readable?Ping
Sorry about the formatting, i did formatted my question againLumbard
G
3

change the following:

@Controller
@RequestMapping

to this:

@Controller

i.e. Remove the @RequestMapping annotation from the class; it provides no value.

Gibbons answered 6/5, 2021 at 4:9 Comment(1)
I tried removing the @RequestMapping but still getting errorLumbard
M
1

This can happens when there is root URL path ("/") in a Spring MVC controller.

In one of the controllers add a @GetMapping("/")

Ex :

@RestController("/")
public class UserController {

    @GetMapping("/")
    public String welcomeUser() {
        return "<h1> Welcome</h1>";
    }

}
Madore answered 20/5, 2023 at 22:2 Comment(0)
P
0

You probably need to specify a mapping for @RequestMapping like @RequestMapping('/')

Ping answered 5/5, 2021 at 13:34 Comment(2)
I did try that , but that was not useful still getting this errorLumbard
@nandanpandey the error is somewhere else thenPing
L
0

I was able to resolve the issue by using mvc:annotation-driven/ in dispatcher xml.

AnnotationMethodHandlerAdapter is removed from Spring 5. So when migrating from Spring 4.x to Spring 5.2.13 I was getting the Adaptor issue.

Lumbard answered 11/5, 2021 at 12:56 Comment(0)
S
0

You need to add both:

@RestController /or @Controller @RequestMapping("your path")

Scarletscarlett answered 3/5, 2023 at 5:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.