pet*_*hel 15 spring spring-mvc spring-3
我的帖子方法被调用,但我的个人资料是空的.这种方法有什么问题?我必须使用@Requestbody来使用RestTemplate吗?
Profile profile = new Profile();
profile.setEmail(email);
String response = restTemplate.postForObject("http://localhost:8080/user/", profile, String.class);
@RequestMapping(value = "/", method = RequestMethod.POST)
public @ResponseBody
Object postUser(@Valid Profile profile, BindingResult bindingResult, HttpServletResponse response) {
//Profile is null
return profile;
}
Run Code Online (Sandbox Code Playgroud)
pet*_*hel 15
您必须以这种方式构建配置文件对象
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
parts.add("email", email);
Object response = restTemplate.postForObject("http://localhost:8080/user/", parts, String.class);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
46904 次 |
| 最近记录: |