不需要PathVariable不起作用

用户名

我得到以下代码:

@GetMapping(value = "/user/{username}/{auth_key}", produces = MediaType.APPLICATION_JSON_VALUE)
public ProfileRequest getUser(final @PathVariable("username") String username,
                              final @PathVariable(value = "auth_key", required = false) UUID authKey) {

而且我不明白为什么/ user / {username}无法处理我的请求。

制造商。

罗马人

/ user / {用户名} / {auth_key}/ user / {用户名}是不同的URL。将所有这些URL放入@GetMapping批注将解决您的问题:

@GetMapping(value = {"/user/{username}/{auth_key}", "/user/{username}/"}, produces = MediaType.APPLICATION_JSON_VALUE)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章