Хорошо, я пытаюсь получить такой JSON
[{"username":"pippo","password":"bla"},{"username":"pluto","password":"bla"},{"username":"topolino","password":"bla"}]
Но я получаю эту ошибку:
Resolving exception from handler [public void sequenziatore.server.presenter.LoginController.CheckLogin(java.util.Vector<sequenziatore.server.presenter.Utente>)]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.util.Vector out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@68c40ef9; line: 1, column: 1]; nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.Vector out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@68c40ef9; line: 1, column: 1]
Resolving exception from handler [public void sequenziatore.server.presenter.LoginController.CheckLogin(java.util.Vector<sequenziatore.server.presenter.Utente>)]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.util.Vector out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@68c40ef9; line: 1, column: 1]; nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.Vector out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@68c40ef9; line: 1, column: 1]
Resolving exception from handler [public void sequenziatore.server.presenter.LoginController.CheckLogin(java.util.Vector<sequenziatore.server.presenter.Utente>)]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.util.Vector out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@68c40ef9; line: 1, column: 1]; nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.Vector out of START_OBJECT token
at [Source: org.apache.catalina.connector.CoyoteInputStream@68c40ef9; line: 1, column: 1]
И это контроллер, который я использую:
@Controller
@RequestMapping(value = "/login")
public class LoginController {
@RequestMapping(method=RequestMethod.POST, consumes = "application/json", produces = "application/json")
@ResponseBody
public void CheckLogin(@RequestBody Vector<Utente> vec) {
.....
}
Я пытался изменить тип, который я получаю с помощью Utente [] вместо Vector, но ничего не изменилось, и настоящая проблема в том, что я не понимаю, в чем ошибка... Это JSON, который я получаю, если я меняю тип получения в String и распечатать...
{"0":{"username":"pippo","password":"bla"},"1":{"username":"pluto","password":"bla"},"2":{"username":"topolino","password":"bla"}}
Это класс Утенте
public class Utente {
private String username=null;
private String password=null;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Utente(){}
}