2011-07-29 37 views

回答

2
@Controller 
@RequestMapping("/foo") 
public class FooController { 

    @Inject private FooService service; 

    @RequestMapping("/create", method=RequestMethod.PUT) 
    public void create(@Valid Foo foo) { .. } 

    @RequestMapping("/retrieve", method=RequestMethod.GET) 
    public String retrieve(@RequestParam String fooId { .. } 

    //etc for POST and DELETE 
} 

(有时人们往往会忽略请求方法的限制,但感觉更RESTful的那样)

+0

+1的方法参数的显式设置。 –