Spring Boot 3 Annotations

 Spring Boot 3 Annotations:


@PathVariable

@GetMapping("/students/{studentId}")
public Student getStudent(@PathVariable int studentId) {
return theStudents.get(studentId);
}


@RequestBody

@PostMapping("/employees")
public Employee addEmployee(@RequestBody Employee theEmployee) {
   //@RequestBody annotation is used to bind the HTTP request body to a method parameter in a controller method.

theEmployee.setId(0);

Employee dbEmployee =
employeeService.save(theEmployee);

return dbEmployee;
}






























Comments