This Spring Boot application demonstrates how to filter custom fields from a User object based on user input.
The application includes a UserController that exposes an endpoint to retrieve a User object with specified fields. The filterFields method in the controller filters out fields that are not included in the request parameter.
- Java JDK 8 or higher
- Maven
- Clone the repository:
git clone https://github.com/abhishekshah2905/spring-filter-custom-fields.git- Navigate to the project directory:
cd spring-filter-custom-fields- Build the project:
mvn clean install- Run the application:
mvn spring-boot:run- Access the application at http://localhost:8089
- Use the / endpoint with a query parameter fields to specify which fields to include in the response. For example, /users?fields=name,age will return a User object with only the name and age fields.