更新时间:2022-06-27 05:55:11
你没有告诉spring如何绑定名称
和电子邮件参数。例如,通过添加 @RequestParam
:
You did not tell spring how to bind the name
and email
parameters from the request. For example, by adding a @RequestParam
:
public @ResponseBody User updateUser(@PathVariable("id") long id,
@RequestParam String name,
@RequestParam String email) { ... }
name
和 email
参数将从查询中填充请求中的字符串。例如,如果您向 /users/1?name=Josh&email=jb@ex.com
发出请求,您将收到以下回复:
name
and email
parameters will be populated from the query strings in the request. For instance, if you fire a request to /users/1?name=Josh&email=jb@ex.com
, you will get this response:
User{id=1, name='Josh', email='jb@ex.com'}
为了更多地了解定义处理程序方法,请查看spring 文档。
In order to gain more insight about defining handler methods, check out the spring documentation.