Accessing multiple controllers with same request mapping

前端 未结 3 1700
野的像风
野的像风 2020-12-16 14:12

Please find my HomeController and DemoController

class HomeController{
@RequestMapping(value=\"index\")
public void home(){
}
}

class DemoController{
@Reque         


        
3条回答
  •  死守一世寂寞
    2020-12-16 14:55

    Unfortunately, this is not possible. The request mapping has to be unique otherwise the application can't determine which method the incoming request should be mapped to.

    What you can do instead is to extend the request mapping:

    class HomeController{
    
       @RequestMapping(value="home/index")
       public void home(){
       }
    }
    
    class DemoController{
    
       @RequestMapping(value="demo/index")
       public void demo(){
       }
    }
    

提交回复
热议问题