Spring MVC - Request mapping, two urls with two different parameters

前端 未结 3 2083
傲寒
傲寒 2020-12-17 22:22

Is it possible in Spring to have one method with two different urls with different params for each method?

Below is pseudo code

@RequestMethod(URL1-p         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-17 22:41

    you can supply multiple mappings for your handler like this

    @RequestMapping(value={"", "/", "welcome"})
    public void handleAction(@ModelAttribute("A") A a, ...) { }
    

    But if you want to use different parameters for each mapping, then you have to extract your method.

提交回复
热议问题