Announcement Announcement Module
Collapse
No announcement yet.
convention over configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FilipeSabella
    started a topic convention over configuration

    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.

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

    That worked perfectly, thanks.

    Leave a comment:


  • Rossen Stoyanchev
    replied
    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() {
            // ...
        }
    
    }

    Leave a comment:

Working...
X