搭建springboot项目在新建的页面引入jquery,报404,找不到js文件。作为一名后端,对于这个问题,我也是很Dan疼,虽然知道这是被内置的springmvc给拦截了,没放行。可是springboot不熟悉,一顿乱配,毛用没有。经过我这面向百度编程的深厚功底,最终还是找到了答案。

1. 确保的你引入的js格式 type  和  <script></script>

<script type="text/javascript" src="static/jquery-3.4.1.min.js"></script>

2. springboot的默认配置文件application.yml或者application.properties配置:

spring:
  thymeleaf:
    prefix: classpath:/templates/
    suffix: .html
    mode: HTML5
    encoding: UTF-8
    cache: false
  mvc:
    static-path-pattern: /static/**
    resources:
      chain:
        strategy:
          content:
            enabled: true
            paths: /**

OK,完事。完美解决。