thymeleaf各种问题,标签没用?网页404?
首先html的网页
//注意这个xmlns后面一定是https,我的就是没加s导致无法识别msg这种变量
Thymeleaf 语法其次,html文件基本都说是放在templates文件夹下,然后用application.properties写一下解析器(前4行应该都必要写上去)
spring.resources.static-locations=classpath:/templates/
spring.thymeleaf.cache=false
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
最重要的导入的包!!!!我可能这一天就死在导包上了
1.8
2.1.1
UTF-8
UTF-8
//下面是我觉得必须要用到的包,反正我少一个就起不来,百度上的也没总结,我就自己写了
org.thymeleaf
thymeleaf-spring5
3.0.11.RELEASE
org.springframework.boot
spring-boot-starter-thymeleaf
net.sourceforge.nekohtml
nekohtml
org.springframework.boot
spring-boot-devtools
runtime
true
org.thymeleaf
thymeleaf
3.0.9.RELEASE
当然web的包是必要的这边也再做下累述吧。嫌自己看包麻烦想复制粘贴配置的请复制下面的
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.7.RELEASE
1.8
2.1.1
UTF-8
UTF-8
com.joel.shiro
01-demo-shiro
1.0.0
01-demo-shiro
Project for Spring Boot
org.thymeleaf
thymeleaf-spring5
3.0.11.RELEASE
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-thymeleaf
net.sourceforge.nekohtml
nekohtml
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-devtools
runtime
true
javax.servlet
javax.servlet-api
javax.servlet.jsp
javax.servlet.jsp-api
2.3.1
org.apache.tomcat.embed
tomcat-embed-jasper
javax.servlet
jstl
org.thymeleaf
thymeleaf
3.0.9.RELEASE
org.apache.shiro
shiro-spring
1.4.0
org.springframework.boot
spring-boot-maven-plugin
src/main/java
**/*.xml
src/main/resources
**/*.*
src/main/webapp
META-INF/resources
**/*.*
最后的话,controller层基本应该没什么问题的,后台传个值到前台。这里也不多做累述。