Implementing DELETE Method to Delete a User Resource12 Dec 2025 | 2 min read In this section, we will implement a delete method to delete a user resource. Step 1: Open the UserDaoService.java file. Step 2: Create a method to delete a user resource. UserDaoService.java
Step 3: Open the UserResource.java file and create a delete mapping to delete a user resource. UserResource.java Step 4: Open Postman, select DELETE request, and specify the user id which you want to delete. Now click on the Send button. ![]() It deletes user id: 3 and returns the Status: 200 Ok. Again send the Get request. It shows all users except user 3. ![]() In the following image, we are trying to delete user id: 9, which does not exist. Hence it returns the Status: 404 Not Found. ![]() |
Introduction to RESTful Web Services With Spring Boot
Introduction to RESTful Web Services REST stands for REpresentational State Transfer. It is developed by Roy Thomas Fielding, who also developed HTTP. The main goal of RESTful web services is to make web services more effective. RESTful web services try to define services using the different...
2 min read
Internationalization of RESTful Services
In this section, we will discuss the Internationalization of the RESTful Web Services. Internationalization Internationalization is the process of designing web applications or services in such a way that it can provide support for various countries, various languages automatically without making the changes in the application. It...
4 min read
Implementing Exception Handling- 404 Resource Not Found
In the ious section, we had returned the proper response status of CREATED when we created the resource. In this section, we will discuss what should be the response when a user resource does not exist. Let's try and execute a simple response. Step 1: Open Rest...
2 min read
Implementing HATEOAS for RESTful Services
HATEOAS HATEOAS acronyms for Hypermedia as the Engine of Application State. The term hypermedia refers to content that contains a link to other forms of media like images, movies, and text. It is a component of the REST application that distinguishes it from other network architecture....
3 min read
Implementing a GET service to retrieve all Posts of a User
In this section, we will retrieve all the posts of a specific user. Step 1: Open the UserJPAResource.java file and create a mapping for the URI "/jpa/users/{id}/posts" @GetMapping("/jpa/users/{id}/posts") public List<Post> retriveAllUsers(@PathVariable int id) { Optional<User> userOptional= userRepository.findById(id); if(!userOptional.isPresent()) { throw new UserNotFoundException("id: "+ id); } return userOptional.get().getPosts(); } Step 2: There is no need to show user...
1 min read
Enhancing the Hello World Service with a Path Variable
The @PathVariable annotation is used to extract the value from the URI. It is most suitable for the RESTful web service where the URL contains some value. Spring MVC allows us to use multiple @PathVariable annotations in the same method. A path variable is a...
3 min read
Implementing POST Service to Create a Post for a User
In this section, we will enable post-operation to create a post for the specific user. Step 1: Open the UserJPAResource.java file and create a PostMapping to create a post. @PostMapping("/jpa/users/{id}/posts") public ResponseEntity<Object> createUser(@PathVariable int id, @RequestBody Post post) { Optional<User> userOptional= userRepository.findById(id); if(!userOptional.isPresent()) { throw new UserNotFoundException("id: "+ id); } User user=userOptional.get(); //map the user to...
1 min read
Creating Post Entity and Many to One Relationship with User Entity
In this section, we will create a Post entity that contains many to one relationship with the User entity. Step 1: Create a class with the name Post.java in the package com.javatpoint.server.main.user. Step 2: Post.java is an entity, so we need to add @Entity annotation. Step 3: Add...
3 min read
Versioning RESTful Web Services-Basic Approach With URIs
Versioning is the most important and difficult part of the API as it takes backward API compatible. Versioning helps us to iterate faster when the changes are identified. We should always version our Web API. Consider a scenario in which we have a Web API that...
6 min read
Enhancing Swagger Documentation with Custom Annotations
In the ious section, we have learned about API documentation. We saw a high-level overview structure of the Swagger documentation. In this section, we will customize the Swagger element info. Swagger annotations are defined in the swagger-annotations-1.5.20.jar file. Step 1: Open the SwaggerConfig.java. Step 2: Create a...
4 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India


