Issue
I want to take an id as input by the user and pass to the controller to get the data of particular id
it's working when I pass id manually in URL -- http://localhost:8080/student/1
<form th:action="@{{student}/{id}}" th:object="${Student}" method="post">
Roll Number:<br>
<input type="text" th:field="*{id}"><br>
<br><br>
<input class="button" type="submit" value="Submit">
</form>
@GetMapping(value = "/student/{id}")
public Optional<Student> getStudentDetail(@PathVariable int id){
return studentRepository.findById(id) ;
}
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Jun 19 11:04:22 IST 2019 There was an unexpected error (type=Internal Server Error, status=500). An error happened during template parsing (template: "class path resource [templates/student.html]")
Solution
change as AmirBll said, Also, you have to change your controller HTTP
method from @GetMapping(value = "/student/{id}")
to @PostMapping(value = "/student/{id}")
as form data
submission is POST
method you declared in the form.
Answered By - user404