我在春季實施SPRING數據JPA + Oracle STS ......在郵遞員我得到的獲取方法,但對於後響應200它is`sample應用程序並將無法讀取從DB我猜的數據並在下面給出錯誤 -無法讀取HTTP消息:org.s.HttReadableException:無法讀取文檔:無法識別的令牌'PUT':期待('true','false'或'null')
無法讀取HTTP消息: org.springframework.http.converter.HttpMessageNotReadableException: 無法讀取文檔:無法識別的令牌「PUT」:在[Source: [email protected]期待 ('true','false'或'null') 6E7;行:1,列:5];嵌套0異常是com.fasterxml.jackson.core.JsonParseException: 無法識別的令牌'PUT':期待('true','false'或'null') at [Source:[email protected];行:1,柱:5]
@Service
public class PersonService {
@Autowired
private PersonRepository personRepository;
public Object findAll() {
return personRepository.findAll();
}
public Person findById(Long id) {
return personRepository.findOne(id);
}
public Person save(Person person) {
return personRepository.save(person);
}
public Person delete(Person person) {
personRepository.delete(person);
return person;
}
public Person findByEmail(String email){ return null; }
}
控制器方法:
@RequestMapping(value = "/all", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Hashtable<String, Person> gatAll() {
return personService.getAll();
}
@RequestMapping(value = "/update/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String updateUser(@RequestBody Person person, @PathVariable long id) {
try {
person.setId(id);
personService.save(person);
} catch (Exception ex) {
return "Error in Updating the user : " + ex.toString();
}
return "User successfully Updated";
}