Results 1 to 3 of 3

Thread: convention over configuration

  1. #1

    Default convention over configuration

    Hello,

    I'm trying Spring Web 2.5 for about 5 hours now.

    I want to do something like this:

    Code:
    Controller
    class PersonController {
        public void list() {
            return list;
        }
    }
    And be able to call it with: /app/person/list

    But I must be doing something terribly wrong, because I can't make it work without using
    Code:
    RequestMapping("/person/list")
    on the method.

    I tried using
    Code:
    <bean id="urlMapping" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
    without success.

    Can someone help?

    Thanks in advance.

  2. #2
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    Add RequestMapping to indicate it's a request handling method. It's also good practice to indicate the request method:
    Code:
    @Controller
    class PersonController {
    
        @RequestMapping(method=RequestMethod.GET)
        public void list() {
            // ...
        }
    
    }

  3. #3

    Default

    Well, I did some wrong mix somewhere in between the tries.

    That worked perfectly, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •