This is a simple Spring Boot application that provides APIs to manage student data. It includes endpoints to retrieve all students and filter students by their registration number.
- Java
- Spring Boot
- REST API
- Endpoint:
GET /api-student/get-all - Description: Retrieves a list of all students.
- Response Example:
[ { "regNu": "2020-ict-01", "name": "sharada", "age": 25, "department": "ict" }, { "regNu": "2020-ict-02", "name": "kanchana", "age": 25, "department": "ict" }, { "regNu": "2020-ict-03", "name": "Liyanage", "age": 26, "department": "ict" } ]
- Endpoint:
GET /api-student/filter-by/{regNu} - Description: Retrieves student details based on the registration number.
- Example Request:
GET /api-student/filter-by/2020-ict-02 - Response Example:
{ "regNu": "2020-ict-02", "name": "kanchana", "age": 25, "department": "ict" }
- Clone the repository:
git clone https://github.com/sharada0417/Spring_boot_model-controllers.git
- Navigate to the project directory:
cd Spring_boot_model-controllers - Run the application using Maven:
mvn spring-boot:run
- The API will be available at
http://localhost:8080.
- Solution: Ensure
/api-student/get-allis called first to populate the list. - Alternative: Modify the method to return an error message instead of
null.
- Solution:
git add . git commit -m "Initial commit" git push -u origin main
Sharada