springboot在controller返回数据到thymeleaf报404
用springboot做一个例子,访问controller可以返回数据,但是到thymeleaf却报404,
检查发现路径等没有问题,查阅资料得知
这是因为maven仓库jar包问题,把maven仓库中的所有jar包都删除了,然后重新下载,再启动项目
或者在pom文件的
properties
标签下加入
1 2 | < thymeleaf.version >3.0.2.RELEASE</ thymeleaf.version > < thymeleaf-layout-dialect.version >2.1.1</ thymeleaf-layout-dialect.version > |
Thymeleaf页面的jquery无效
在<head>标签中写的jquery无效
1 2 3 4 5 6 7 8 9 | <! DOCTYPE html> < html lang="en" xmlns:th="http://www.thymeleaf.org"> < head th:include="fragment::header"> < meta charset="UTF-8"> < title ></ title > < script > ...... // 此处会被覆盖 </ script > </ head > |
原因:使用 <head th:include="fragment::header"> 集中引入外部资源时,会覆盖原页面中的<head>标签,则<script>标签中的代码在页面源码会不存在
引入后的页面源码<head>:
1 2 3 4 5 6 7 8 9 10 | <! DOCTYPE html> < html lang="en"> < head > < meta charset="UTF-8"> < link href="/css/style.css" rel="stylesheet"/> < link href="/bootstrap/css/bootstrap.css" rel="stylesheet"/> < script src="/js/jquery-3.0.0.min.js" type="text/javascript"></ script > < script src="/bootstrap/js/bootstrap.js" type="text/javascript"></ script > < title >fragment</ title > </ head > |
from:https://www.cnblogs.com/shiysin/p/10569707.html