springboot+thymeleaf模板不通过controller直接跳转静态页面
今天在使用springboot+thymeleaf模板开发时遇到超链接跳转页面404的问题,开始以为是url格式的错误,查看请求路径时发现,每次请求的路径都请求到了controller,找到如下解决办法,记录下来供以后学习。
在application.yml中加入以下配置
# Spring配置
spring:
resources:
static-locations: classpath:/static/, classpath:/templates/
页面静态请求的格式
<span class="text-warning"><a th:href="@{xy/zb/dktarget.html}">测试</a></span>
附上thymeleaf中通过controller请求返回页面格式
th:href="@{${请求的url}}"。