No adapter for handler exception

后端 未结 2 1914
渐次进展
渐次进展 2020-12-07 11:40

I\'m developing a web application using spring mvc framework. I want to to both annotation and beanName based url mappings.

I\'ve the following configurations in my

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 11:58

    By default the spring mvc defines 3 different request handler adapters, they are

    org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter
    org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
    

    So you need not have to define them in your context file, but if you define at least one handler adapter in your context files, spring will not create the default adapters.

    In your configuraion you are using , according to this spring documentation this will cause the context to define both DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter. Since we are creating the AnnotationMethodHandlerAdapter in our context definition spring will not create the other two handlerAdapters. That is why you are getting the said exception.

    The beanNameUrlMapping needs the handlerAdapter SimpleControllerHandlerAdapter.

    To resolve this exception you can simply create a new bean of type "SimpleControllerHandlerAdapter" in your context.

    
    
    

提交回复
热议问题