本文共 944 字,大约阅读时间需要 3 分钟。
使用环境:使用shpringboot搭建项目时候,后台COntroller返回页面地址报错提示找不到index.html。
原因:在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错。
解决方案:
1、添加依赖
org.springframework.boot spring-boot-starter-thymeleaf
2、配置环境
#thymelea模板配置spring.thymeleaf.prefix=classpath:/templates/spring.thymeleaf.suffix=.htmlspring.thymeleaf.mode=HTML5spring.thymeleaf.encoding=UTF-8spring.thymeleaf.content-type=text/htmlspring.thymeleaf.cache=falsespring.resources.chain.strategy.content.enabled=truespring.resources.chain.strategy.content.paths=/**spring.mvc.static-path-pattern=/static/**
3、(重要!!!)前端页面修改
kevin-视频播放
Note: html默认是<html lang="en">格式,就是这种格式导致无法解析为thymeleaf。将页头改为<html lang="en" xmlns:th="http://www.thymeleaf.org">即可解决问题。
转载地址:http://hfuqb.baihongyu.com/