Science & Technology

#16 Spring Web PUT and DELETE

by Telusko

Share:

📚 Main topics

  • Updating products with PUTThe tutorial adds a PUT mapping that accepts a product in the request body and delegates the update to the service. The service finds a matching product ID in the hardcoded list and replaces that entry. 2:05
  • Deleting products with DELETEA DELETE mapping accepts the product ID from the URL as a path variable. The service finds the matching list index and removes that product. 7:24

✨ Key takeaways

  • Testing with PostmanThe PUT request initially failed because its body was sent as text rather than JSON. After changing the request format, the update succeeded; a GET request confirmed the change. 6:22
  • In-memory data is temporaryProducts are kept in a hardcoded list, so restarting the application resets the data. 1:01
  • Verify the resultAfter sending a DELETE request, a GET request confirms the selected product is gone. 10:59

🧠 Lessons learned

  • Manual list handling has limitationsFinding products by looping through the list works for this example, but the code could be improved by extracting common logic and handling IDs that are not found. 9:27
  • Database persistence can simplify updatesThe instructor notes that Spring Data JPA will make this kind of data operation easier in upcoming videos. 3:08

🏁 Conclusion/next steps

  • CRUD methods coveredThe video completes the GET, POST, PUT, and DELETE operations for products using Spring Boot and Spring MVC. 11:29
  • What comes nextThe instructor says the upcoming videos will continue the series. 11:29

Transcript excerpt

0:00 now it's time to write the code for the update and delete so what we have done till now is basically we have this products uh page or the controller and we are sending a request to get all the products we are getting that on the client side it can be a browser or it can be a uh API client like Postman and then we are also fetching one product details or we are able to add new products and we have done that in Postman so if I open my post man so this

0:30 was the request right so we have sent the get request using which you were getting the uh products we have also done with the post request and the post basically we are sending data as well so what we'll do is before we go for the update and delete let me add this product and then we'll do that and I can't do this now so if I send a request it says the server is not running so to make sure the server is running so I will just restart the application and hopefully this time there will not be an issue uh because I'm recording after a long time and if you see here here uh

🔒 The full, searchable transcript is available with Pro.

🔒 Unlock Premium Features

This is a premium feature. Upgrade to unlock unlimited Q&A, transcripts, mindmaps, and translations.

🔒 Unlock Premium Features

Access to Chat is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Mindmap is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Translation is a premium feature. Upgrade now to unlock unlimited studying tools.

Get unlimited summaries, Q&A, transcripts and more with Pro

Upgrade to Pro

Suggestions

🔒 Unlock Premium Features

Access to AI Suggestions is a premium feature. Upgrade now to unlock unlimited studying tools.