When I am pressing delete button I am redirected to the link attached to this button while I want be the same page while I use ResponseEntity
.
Here is the button:
<td><a type="button" class="btn btn-warning" href="/delete-todo?id=${todo.id}">DELETE</a></td>
Here is my controller:
@RequestMapping(value="/delete-todo")
public ResponseEntity<Void> deleteTodo(@RequestParam int id){
todoService.delete(id);
return ResponseEntity.ok().build();
}
Can anyone tell what I'm doing wrong with ResponseEntity
.
Simply return remove redirect should work:
@RequestMapping(value="/delete-todo")
public String deleteTodo(@RequestParam int id){
todoService.delete(id);
return "/todo-list";
}