嗯,我試圖在spring控制器中檢索嵌套的JSON並獲取400(錯誤請求)錯誤。發佈嵌套的JSON到彈簧控制器
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的
也發佈你的錯誤。 –
我使用REST客戶端擊中請求,並收到此錯誤 HTTP狀態400 - 型狀態報告 消息 說明通過客戶端發送的請求是語法不正確()。 JBoss Web/7.0.13.Final 控制檯上什麼都沒有 –
怎麼回事調試?你可以做調試,並檢查哪一行導致錯誤。 –