I have a case that I have a list page which list all the items and each item has a delete link. User can click this link to delete this item, this is the delete link format: http://localhost:8080/list.htm?op=del&id=1234
When user click the delete link, it will return to the list page. But this has a problem that when user refresh the page, it will invoke the delete operation again which will cause error. So How can I change the URL when the server side set back the response? I want the link still to be
http://localhost:8080/list.htm
Thanks
BTW I am using Spring MVC
Jeff Zhang
Assuming you are not returning any data on the delete operation, just return an HTTP 303 response with the Location header set to ‘list.htm’. Alternatively, you can do this via JavaScript on the client side after the response is received:
I would suggest, however, having a separate endpoint to delete. Using an endpoint called list to delete an object doesn’t make sense; instead, the link should hit an endpoint such as delete.htm?id=1234 (which can then send the 303 to redirect back to list.htm).