【SpringBoot+Mybatis+thymeleaf报错】Error resolving template "XXX", template might not exist or might not be accessible by any of the configured
解决方法一:
原因:在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错。
在application.yml中添加以下配置
spring:
thymeleaf:
prefix: classpath:/templates/
mode: HTML
cache: false
encoding: UTF-8
# 新版本不支持content-type: text/html,故新写法
servlet:
content-type: text/html
再在pom.xml 添加以下依赖
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
解决方法二:
原因:Spring Boot没有解析出静态资源文件位置
<build>
<!-- 配置将哪些资源文件(静态文件/模板文件/mapper文件)加载到tomcat输出目录里 -->
<resources>
<resource>
<directory>src/main/java</directory><!--java文件的路径-->
<includes>
<include>**/*.*</include>
</includes>
<!-- <filtering>false</filtering>-->
</resource>
<resource>
<directory>src/main/resources</directory><!--资源文件的路径-->
<includes>
<include>**/*.*</include>
</includes>
<!-- <filtering>false</filtering>-->
</resource>
</resources> <plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
解决方法三:
原因:这个是我自己的锅,我原先使用的是freemaker引擎,文件格式为.ftl,故切换thymeleaf引擎后没有改为.html,修改文件后缀即可。
解决方法四:
原因:可能是由于找不到前端VIew路径的原因。
具体参考我的后台(注意ModelAndView的值):
@GetMapping("/listUser")
public ModelAndView listUser(){
ModelAndView model = new ModelAndView("user/list");
model.addObject("userList",userservice.listUser());
return model;
}
项目结构:
实在找不到,application.yml中加入:
spring:
thymeleaf:
prefix: classpath:/templates/
【SpringBoot+Mybatis+thymeleaf报错】Error resolving template "XXX", template might not exist or might not be accessible by any of the configured的更多相关文章
- 关于Springboot+thymeleaf +MybatisPlus 报错Error resolving template [index], template might not exist的问题解决
这个问题困扰了我整整一上午,各种方式,什么返回路径 ,静态资源啊 什么的,能想到的都去搞了,可是问题还是解决不了!!!我查看了一下编译文件的[target]文件夹!发现了问题所在!根本就没有编译进去! ...
- git切换分支报错:error: pathspec 'origin/XXX' did not match any file(s) known to git
项目上有一个分支test,使用git branch -a看不到该远程分支,直接使用命令git checkout test报错如下: error: pathspec 'origin/test' did ...
- 报错Error resolving template template might not exist or might not be accessible解决方案
"C:\Program Files\Java\jdk1.8.0_144\bin\java" "-javaagent:D:\IntelliJ IDEA Community ...
- SpringBoot启动zipkin-server报错Error creating bean with name ‘armeriaServer’
目前,GitHub 上最新 release 版本是 Zipkin 2.12.9,从 2.12.6 版本开始有个较大的更新,迁移使用 Armeria HTTP 引擎. 从此版本开始,若直接添加依赖的 S ...
- SpringBoot启动zipkin-server报错Error creating bean with name ‘armeriaServer’ defined in class path resource
目前,GitHub 上最新 release 版本是 Zipkin 2.12.9,从 2.12.6 版本开始有个较大的更新,迁移使用 Armeria HTTP 引擎. 从此版本开始,若直接添加依赖的 S ...
- SpringBoot+MyBatis整合报错Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
项目启动的时候报这个错误,这个问题我百度了一天,果然不出意外的还是没能解决,其中有一篇文章相对来说还是有点用的:https://blog.csdn.net/qq8693/article/details ...
- 异常:Error resolving template "xxx", template might not exist or might not be accessible...解决办法
在开发环境下正常,但使用jar运行时,报错Error resolving template template might not exist or might not be accessible,意思 ...
- org.thymeleaf.exceptions.TemplateInputException: Error resolving template 报错
org.thymeleaf.exceptions.TemplateInputException: Error resolving template报错 遇到二次,第一次是刚刚学的时候,都是一个原因,而 ...
- org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/ template might not exist or might not be accessible by any of the configured
异常现象:在本地打包部署完全没有问题,资源文件也都可以映射上,但是打包成jar包部署到服务器上时,就一直报异常,异常信息如下: 严重: Servlet.service() for servlet [d ...
随机推荐
- 运行Junit单测时遇到的问题
现在有两个办法解决: 1.junit版本降到4.10 2.导入hamcrest-core-1.3.jar 官网:JUnit now uses the latest version of Hamcres ...
- OSX 下 sftp 上传目录到服务器
使用如下命令: put –r dir mput –r dir
- 全球数据库-->基金/管理产品-->基金分析/新闻/报告
加拿大共同基金 澳大利亚投资信托 美国ETF 美国共同基金 英国投资信托基金 名称 分析师名称 分析日期 晨星分析师评级 晨星简报
- 2016-2017-20155329 《Java程序设计》第6周学习总结
学号 2016-2017-20155329 <Java程序设计>第6周学习总结 教材学习内容总结 数据从来源取出:输入串流 java.io.InputStream 写入目的的:输出串流 j ...
- UVa 12093 Protecting Zonk (树形DP)
题意:给定一个有n个节点的无根树,有两种装置A和B,每种都有无限多个.在某个节点X使用A装置需要C1的花费,并且此时与节点X相连的边都被覆盖.在某个节点X使用B装置需要C2的花费,并且此时与节点X相连 ...
- 这可能是AI、机器学习和大数据领域覆盖最全的一份速查表
https://mp.weixin.qq.com/s?__biz=MjM5ODE1NDYyMA==&mid=2653390110&idx=1&sn=b3e5d6e946b719 ...
- BI使用者的角色
把企业中的BI使用者的角色分成如下几类: 系统管理员:没有数据权限:没有功能权限:负责配置其他人的权限:BI专家:拥有所有数据权限:拥有多维分析,报表查看,报表开发,模型开发权限:负责开发和维护BI系 ...
- [leetcode] 6. Balanced Binary Tree
这个题目纠结了一会儿,终于从二叉树转化到AVL了.题目如下: Given a binary tree, determine if it is height-balanced. For this pro ...
- 我的第一个博客&GuiHub简单练习
个人介绍 姓名:马瑞 性别:男 班级:网络工程143 出生年月:1995.11 兴趣爱好:玩玩电脑,看看动漫. 编程能力:完全是菜鸟. GutHub的使用体验: 第一步:注册github,这很简 ...
- CURL命令测试网站打开速度
curl -o /dev/null -s -w %{time_namelookup}:%{time_connect}:%{time_starttransfer}:%{time_total} http: ...