【问题标题】:No adapter for handler : The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler处理程序没有适配器:DispatcherServlet 配置需要包含一个支持此处理程序的 HandlerAdapter
【发布时间】:2021-07-27 18:16:59
【问题描述】:

我们正在从 spring 4.x 迁移到 spring 5.2.13 版本。在 spring 4 中这是有效的,但在 spring 5.x 中,我们收到以下调度程序 servlet 错误

javax.servlet.ServletException: No adapter for handler : DispatcherServlet 配置需要包含一个支持此处理程序的 HandlerAdapter 在

谁能帮助我,我在这里缺少什么? 我正在从 spring 4.x 迁移到 spring 5.2.13

【问题讨论】:

  • 如何格式化您的问题以使其可读?
  • 抱歉格式化,我确实再次格式化了我的问题

标签: java spring spring-boot spring-mvc


【解决方案1】:

我能够通过在调度程序 xml 中使用 mvc:annotation-driven/ 来解决该问题。

AnnotationMethodHandlerAdapter 已从 Spring 5 中删除。因此,当从 Spring 4.x 迁移到 Spring 5.2.13 时,我遇到了适配器问题。

【讨论】:

    【解决方案2】:

    更改以下内容:

    @Controller
    @RequestMapping
    

    到这里:

    @Controller
    

    即从类中移除@RequestMapping注解; 它没有任何价值。

    【讨论】:

    • 我尝试删除 @RequestMapping 但仍然出现错误
    【解决方案3】:

    您可能需要为@RequestMapping 指定一个映射,例如@RequestMapping('/')

    【讨论】:

    • 我确实尝试过,但仍然出现此错误并没有用
    • @nandanpandey 错误出现在其他地方
    猜你喜欢
    • 2017-03-15
    • 2014-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-20
    • 1970-01-01
    • 2021-08-11
    相关资源
    最近更新 更多