How to know which param of @RequestMapping is called

后端 未结 3 1452
被撕碎了的回忆
被撕碎了的回忆 2021-01-22 09:48

This is my @RequestMapping annotation:

  @RequestMapping({\"/loginBadCredentials\", \"/loginUserDisabled\", \"/loginUserNumberExceeded\"})
  public          


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-22 10:34

    you can inject the HttpServletRequest into the method-parameters and then get the called uri.

      @RequestMapping({"/loginBadCredentials", "/loginUserDisabled", "/loginUserNumberExceeded"})
      public String errorLogin(HttpServletRequest request) {        
                String uri = request.getRequestURI(); 
                // do sth with the uri here
      }
    

提交回复
热议问题