I have following Spring Boot project structure (using Thymeleaf) -
Now, when I tried to reference defect-details.html
from index.html
it could not be found. I tried all the following options to no avail:
1.<a th:href="@{/defect-details.html}">
2.<a th:href="@{defect-details.html}">
3.<a href="defect-details.html">
Every time it says There was an unexpected error (type=Not Found, status=404)
.
Please help to find the issue.
(As JBNizet pointed out in the comment) As per MVC design architecture it's better to use controller to render the views instead of view-to-view links. All I had to do was update my Controller class with:
@RequestMapping("/defect-details")
public String defectDetails() {
return "defect-details";
}
And in the Thymeleaf template:
<a th:href="@{defect-details}">