500 Internal Error
The Students are updating but i am getting this error after clicking to update button . This are the both controller Can Anyone Help !
@GetMapping("/edit")
public String getUpdateStudent(@RequestParam Long roll_no, @RequestParam Long bookId, Model model) {
log.info("Received roll_no: {}, bookId: {}", roll_no, bookId);
StudentDetailUpdate studentDetailUpdate = new StudentDetailUpdate();
model.addAttribute("roll_no", roll_no);
model.addAttribute("bookId", bookId);
model.addAttribute("studentDetails", studentDetailUpdate);
return "updatestudent";
}
@PostMapping("/updatestudent")
public String updateStudent(@Valid @ModelAttribute("studentDetails") StudentDetailUpdate studentDetailUpdate,
BindingResult result, Model model) {
log.info("Updating student with roll_no: {}, bookId: {}", studentDetailUpdate.getRoll_no(),
studentDetailUpdate.getBookId());
if (result.hasErrors()) {
return "updatestudent";
}
try {
studentDetailsService.updateStudentNameAndReturnDate(studentDetailUpdate.getRoll_no(),
studentDetailUpdate.getBookId(), studentDetailUpdate.getName(),
studentDetailUpdate.getReturnDate());
return "viewmore";
} catch (StudentNotFound | ResourceNotFoundException e) {
return "updatestudent";
}
} @GetMapping("/edit")
public String getUpdateStudent(@RequestParam Long roll_no, @RequestParam Long bookId, Model model) {
log.info("Received roll_no: {}, bookId: {}", roll_no, bookId);
StudentDetailUpdate studentDetailUpdate = new StudentDetailUpdate();
model.addAttribute("roll_no", roll_no);
model.addAttribute("bookId", bookId);
model.addAttribute("studentDetails", studentDetailUpdate);
return "updatestudent";
}
@PostMapping("/updatestudent")
public String updateStudent(@Valid @ModelAttribute("studentDetails") StudentDetailUpdate studentDetailUpdate,
BindingResult result, Model model) {
log.info("Updating student with roll_no: {}, bookId: {}", studentDetailUpdate.getRoll_no(),
studentDetailUpdate.getBookId());
if (result.hasErrors()) {
return "updatestudent";
}
try {
studentDetailsService.updateStudentNameAndReturnDate(studentDetailUpdate.getRoll_no(),
studentDetailUpdate.getBookId(), studentDetailUpdate.getName(),
studentDetailUpdate.getReturnDate());
return "viewmore";
} catch (StudentNotFound | ResourceNotFoundException e) {
return "updatestudent";
}
}