This project demonstrates how to use Request Parameters (@RequestParam) in a Spring Boot REST API.
It allows users to:
- Fetch student data
- Filter by name
- Sort by marks
- Apply pagination (page & size)
- Java
- Spring Boot
- Spring Web
- Maven
GET /students
GET /students?name=Srinivas&sortBy=marks&page=0&size=5
| Parameter | Description |
|---|---|
| name | Filter students by name |
| sortBy | Sort by field (e.g., marks) |
| page | Page number (starts from 0) |
| size | Number of records per page |
http://localhost:8080/students?name=Srinivas&sortBy=marks&page=0&size=5
[
{"name": "Srinivas", "marks": 95},
{"name": "Srinivas", "marks": 92},
{"name": "Srinivas", "marks": 88}
]- ✔ Filtering using
@RequestParam - ✔ Sorting using
Sort - ✔ Pagination using
Pageable - ✔ Clean REST API design
- Clone the repository
- Open in IDE (IntelliJ / Eclipse)
- Run the Spring Boot application
- Use Postman or browser to test APIs
@GetMapping("/students")
public List<Student> getStudents(
@RequestParam(required = false) String name,
@RequestParam(defaultValue = "marks") String sortBy,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "5") int size) {
// logic here
}Srinivas Dappu Java Full Stack Developer