Difference between path and value attributes in @RequestMapping annotation

后端 未结 3 1563
旧巷少年郎
旧巷少年郎 2021-01-07 16:54

What is the difference between below two attributes and which one to use when?

@GetMapping(path = \"/usr/{userId}\")         


        
3条回答
  •  渐次进展
    2021-01-07 17:09

    @GetMapping is an alias for @RequestMapping

    @GetMapping is a composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET).

    value method is an alias for path method.

    This is an alias for path(). For example @RequestMapping("/foo") is equivalent to @RequestMapping(path="/foo").

    So both methods are similar in that sense.

提交回复
热议问题