I know theres a similar question in stackoverflow like mine. I tried every answer that i could from this question none of these worked: Thymeleaf using path variables to th:href
Can you help me what did i wrong in my thymeleaf page? URL that i would like to reach: localhost:8081/students/{stu_id}
My GetMapping looks like:
@GetMapping("/students")
public ModelAndView viewStudentPage() {
List<Student_Dim> listStudent = studentService.getAllStudents();
return new ModelAndView("students","students", listStudent);
}
@GetMapping("/students/{id}")
private ModelAndView getInfo(@PathVariable("id") String stu_id){
Student_Dim student = studentService.getStudentById(stu_id);
return new ModelAndView("student","student",student);
}
Href that i use (students.html):
<tbody>
<tr th:each="student : ${students}">
<td th:text="${student.stu_fname}">First Name</td>
<td th:text="${student.stu_lname}">Last Name</td>
<td th:text="${student.dep_code}">Department Code</td>
<td th:text="${student.fac_code}">Faculty Code</td>
<td th:text="${student.loc_code}">Location Code</td>
<td th:text="${student.marriage_status}">Marriage Status</td>
<td th:text="${student.address}">Address</td>
<td>
<a href="@{/students/{id}(id=${student.stu_id})}">Edit</a>
</td>
</tr>
</tbody>