Spring MVC 3 : Ambiguous mapping found

后端 未结 2 1033
误落风尘
误落风尘 2021-02-13 03:35

I am playing with spring MVC 3.1 and testing different features. I wanted to verify following statement taken from @RequestMapping#value doc

If you have a single         


        
2条回答
  •  执笔经年
    2021-02-13 03:49

    If you have a controller as given below, all requests other than /book/edit will be directed to mydefault() while /book/edit will be sent to meet().

    @Controller
    @RequestMapping("/book")
    public class BookController {
    
        @RequestMapping
        public @ResponseBody String mydefault() {
            return "Hi Book!";
        }
    
        @RequestMapping("/edit")
        public @ResponseBody String meet() {
            return "Nice to meet you Book!";
        }
    }
    

    In your sample you have two methods without explicit path mapping.

提交回复
热议问题