Announcement Announcement Module
Collapse
No announcement yet.
No adapter for handler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No adapter for handler

    I am trying out the @Controller annotation and I keep getting:
    "No adapter for handler [foo.bar.AnnotatedUploadController@1c39d09]: Does your handler implement a supported interface like Controller?"

    spring-servlet.xml
    Code:
      <context:component-scan base-package="foo.bar"/>
      <context:annotation-config/>
    <bean id="testHandler" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
    and my class:
    Code:
    @Controller
    @RequestMapping("/*")
    public class AnnotatedUploadController {
    
    	public String processImageUpload(@RequestParam("image") MultipartFile image) throws IOException {
    
    		System.out.println(image.getName());
    		return "redirect:imageList";
    	}
    }

    When I start the app the debug output shows that it the annotatedupload path is being mapped to the correct controller.

    Code:
    20:25:56,768 DEBUG DefaultListableBeanFactory:214 - Returning cached instance of singleton bean 'annotatedUploadController'
    20:25:56,784 DEBUG ControllerClassNameHandlerMapping:323 - Mapped URL path [/annotatedupload] onto handler [foo.bar.AnnotatedUploadController@13feff2]
    20:25:56,784 DEBUG DefaultListableBeanFactory:214 - Returning cached instance of singleton bean 'annotatedUploadController'
    20:25:56,784 DEBUG ControllerClassNameHandlerMapping:323 - Mapped URL path [/annotatedupload/*] onto handler [foo.bar.AnnotatedUploadController@13feff2]
    20:25:56,784 DEBUG ControllerClassNameHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalCommonAnnotationProcessor': no URL paths identified
    But when I submit the form I get:

    Code:
    20:26:40,658 DEBUG DispatcherServlet:783 - DispatcherServlet with name 'spring' received request for [/test/annotatedupload]
    20:26:40,783 DEBUG DispatcherServlet:845 - Bound request context to thread: org.apache.catalina.connector.RequestFacade@1475479
    20:26:41,033 DEBUG CommonsMultipartResolver:258 - Found multipart file [file] of size 63895 bytes with original filename [recr_lst.csv], stored at [C:\Tomcat\work\Catalina\localhost\test\upload_5be1b2cc_11e14d8d38c__8000
    _00000001.tmp]
    20:26:41,049 DEBUG DispatcherServlet:1045 - Testing handler map [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping@336f59] in DispatcherServlet with name 'spring'
    20:26:41,049 DEBUG DefaultAnnotationHandlerMapping:161 - Looking up handler for [/annotatedupload]
    20:26:41,065 DEBUG DispatcherServlet:1085 - Testing handler adapter [[email protected]4fbe]
    20:26:41,065 DEBUG DispatcherServlet:1085 - Testing handler adapter [org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter@9f6ece]
    20:26:41,065 DEBUG DispatcherServlet:1085 - Testing handler adapter [org.springframework.web.servlet.mvc.throwaway.ThrowawayControllerHandlerAdapter@123a510]
    20:26:41,065 DEBUG DispatcherServlet:1085 - Testing handler adapter [org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter@129d183]
    20:26:41,080 DEBUG CommonsMultipartResolver:278 - Cleaning up multipart file [file] with original filename [recr_lst.csv], stored at [C:\Tomcat\work\Catalina\localhost\test\upload_5be1b2cc_11e14d8d38c__8000_00000001.tmp]
    
    20:26:41,096 DEBUG DispatcherServlet:939 - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@1475479
    20:26:41,096 DEBUG DispatcherServlet:588 - Could not complete request
    javax.servlet.ServletException: No adapter for handler [foo.bar.AnnotatedUploadController@13feff2]: Does your handler implement a supported interface like Controller?
            at org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1091)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
    Any ideas?

  • #2
    You need to tell spring what method to execute in case of a POST request. Check this post for an example or better yet, search the forum for @Controller and @RequestMapping examples.

    Comment

    Working...
    X