I\'m trying to write a simple PUT
request method in Spring MVC. I got the following:
@RequestMapping(value = \"/users/{id}\", method = RequestMe
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
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'}
In order to gain more insight about defining handler methods, check out the spring documentation.