Sai*_*pta 4 spring spring-mvc thymeleaf spring-boot
我有以下 Spring Boot 项目结构(使用 Thymeleaf)-
现在,当我试图引用defect-details.html从index.html它不能被发现。我尝试了以下所有选项均无济于事:
1.<a th:href="@{/defect-details.html}">
2.<a th:href="@{defect-details.html}">
3.<a href="defect-details.html">
每次都说There was an unexpected error (type=Not Found, status=404)。
请帮助查找问题。
(正如JBNizet在评论中指出的那样)根据 MVC 设计架构,最好使用控制器来呈现视图而不是视图到视图的链接。我所要做的就是更新我的 Controller 类:
@RequestMapping("/defect-details")
public String defectDetails() {
return "defect-details";
}
Run Code Online (Sandbox Code Playgroud)
在 Thymeleaf 模板中:
<a th:href="@{defect-details}">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11821 次 |
| 最近记录: |