PUT makes POST instead of updating value in Spring Boot

走远了吗. 提交于 2021-01-29 21:56:08

问题


I don't understand why, but whenever I do put operation in postman this method always creates new vehicle This is code for put mapping

@PutMapping("/{id}")
public Vehicle updateVehicle(@PathVariable long id, @RequestBody Vehicle vehicle){
    vehicle.setVehicleId(id);
    return vehicleRepository.saveAndFlush(vehicle);
}

This is code for post mapping

@PostMapping("")
public Vehicle newVehicle(@RequestBody Vehicle vehicle){
    return vehicleRepository.saveAndFlush(vehicle);
}

来源:https://stackoverflow.com/questions/61920671/put-makes-post-instead-of-updating-value-in-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!