解决springboot+thymeleaf模板不通过controller直接跳转静态页面!!!

    技术2022-07-11  96

    解决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}}"

    刚入门的小白学习中,如有不足或错误还望大神指出。感谢!

    Processed: 0.011, SQL: 9