Announcement Announcement Module
No announcement yet.
Spring MVC step-by-step... with annotations? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC step-by-step... with annotations?

    I tried to use the step-by-step tutorial that comes included with release 2.5.6.

    In step 1.12 it blows up with "No adapter for handler [<controller name here>]: Does your handler implement a supported interface like Controller?"

    Per the tutorial, it does implement Controller, but when double-checking the Controller code I noticed that Eclipse complains that (a) I must use the @Controller annotation, and (b) Explicitly specifying the Controller interface is considered 'duplicate' even when not using the annotation. But if I specify @Controller... it still throws the same error (probably because some 'stuff' is needed in the xml configuration).

    So, my questions are:

    1) Are Annotations now MANDATORY in release 2.5.6? If so, where do I find GOOD documentation about them?

    2) Did somebody mess up and release the wrong version of the step-by-step document with release 2.5.6?

    3) Where can I go for a proper step-by-step tutorial that will work with release 2.5.6.

    4) I am very surprised about this problem. Version 2.5.6 has been out for a while, and I can't be the first one to notice the problem. Is Spring giving up on properly documenting its open source? I hope not, because even the best software is worthless if novices at it can't figure out how to use it.

  • #2
    make sure you have the following in your applicationContext.xml/equivalent
        <context:component-scan base-package=“org.mypackage”/>
    Annotate your class with @Controller and then provide a @RequestMapping annotation to either the entire class:
    class myClass{
       @RequestMapping(method = RequestMethod.GET)
       public void get(...){}
       @RequestMapping(method = RequestMethod.POST)
       public void post(...){}
    or you can map individual methods with the full request path and method
    (if you don't specify a method both get and post will be accepted, can't remember about delete and put) e.g.,
    public void getSomFoo(...){}
    hope that helps.


    • #3
      It did, thank you. I also had to setup a bunch of other beans in xml context. But it now works and I was able to move forward with the tutorial.

      I hope the authors update the document soon.


      • #4
        Originally posted by bmelloni View Post
        I hope the authors update the document soon.
        I agree and vote big time on updating the step-by-step tutorial ASAP. It's very difficult for a newcomer to try to learn Spring 3 MVC with annotations from the reference documentation. An updated tutorial would go a long way towards bringing us newbies up to speed and joining the ranks!