那么我想找回春天控制器嵌套JSON和获取400(错误请求)错误。
JSON
{"AuthenticationInfo":
{"loginId":"243324","password":"xyz"}
}
调节器
@RequestMapping(value = "/login", method = RequestMethod.POST,headers={"Accept=*/*","content-type=application/json"})
@ResponseBody
public MySubscriber getSubscriber(@RequestBody MyAuthentication myAuthentication) {
LOGGER.log(Level.INFO, "getSubscriber");
System.out.println("getSubscriber method : "+myAuthentication);
MySubscriber mySubscriber = helloWebService.getSubscriber(myAuthentication);
LOGGER.log(Level.INFO, "mySubscriber : " + mySubscriber);
System.out.println( "mySubscriber : " + mySubscriber);
return mySubscriber;
}
MyAuthentication
public class MyAuthentication extends AuthenticationInfo {
private AuthenticationInfo AuthenticationInfo;
public AuthenticationInfo getAuthenticationInfo() {
return AuthenticationInfo;
}
public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
AuthenticationInfo = authenticationInfo;
}
@Override
public String toString()
{
return "AuthenticationInfo : "+AuthenticationInfo;
}
}
AuthenticationInfo
public class AuthenticationInfo {
private String loginId;
private String password;
public String getLoginId() {
return loginId;
}
public void setLoginId(String loginId) {
this.loginId = loginId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString()
{
return "{ loginId : "+loginId+" || password"+password+"}";
}
}
当我火只是简单的JSON,并相应地检索它的错误去。 这里唯一的问题是将JSON的嵌套结构