解决方法一:

原因:在使用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的更多相关文章

  1. 关于Springboot+thymeleaf +MybatisPlus 报错Error resolving template [index], template might not exist的问题解决

    这个问题困扰了我整整一上午,各种方式,什么返回路径 ,静态资源啊 什么的,能想到的都去搞了,可是问题还是解决不了!!!我查看了一下编译文件的[target]文件夹!发现了问题所在!根本就没有编译进去! ...

  2. 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 ...

  3. 报错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 ...

  4. SpringBoot启动zipkin-server报错Error creating bean with name ‘armeriaServer’

    目前,GitHub 上最新 release 版本是 Zipkin 2.12.9,从 2.12.6 版本开始有个较大的更新,迁移使用 Armeria HTTP 引擎. 从此版本开始,若直接添加依赖的 S ...

  5. 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 ...

  6. SpringBoot+MyBatis整合报错Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    项目启动的时候报这个错误,这个问题我百度了一天,果然不出意外的还是没能解决,其中有一篇文章相对来说还是有点用的:https://blog.csdn.net/qq8693/article/details ...

  7. 异常: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,意思 ...

  8. org.thymeleaf.exceptions.TemplateInputException: Error resolving template 报错

    org.thymeleaf.exceptions.TemplateInputException: Error resolving template报错 遇到二次,第一次是刚刚学的时候,都是一个原因,而 ...

  9. 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 ...

随机推荐

  1. Java面向对象理解_代码块_继承_多态_抽象_接口

    面线对象: /* 成员变量和局部变量的区别? A:在类中的位置不同 成员变量:在类中方法外 局部变量:在方法定义中或者方法声明上 B:在内存中的位置不同 成员变量:在堆内存 局部变量:在栈内存 C:生 ...

  2. Excel中保留有效数字的问题

    在工作表界面中按 <alt>+<F11>,进入代码页面,然后再 WORKBOOK中插入模块,把以下代码COPY入模块中.就可以在工作表中使用 =YXSZ(数值,保留位数). 如 ...

  3. openpose

    编译libpthread.so pthread2 ihash

  4. ultraiso制作ubuntu u盘启动

    http://blog.csdn.net/yaoyut/article/details/78003061

  5. yum 系列(二) 离线部署

    yum 系列(二) 离线部署 一.下载 rpm 依赖包 (1) yum 下载 rpm 包 准备一台 全新的 CentOS7 mini 虚拟机 ,联网下载所有所需的 rpm 包和其依赖, yum ins ...

  6. linux下的shell运算(加、减、乘、除

    linux下的shell运算(加.减.乘.除 摘自:https://blog.csdn.net/hxpjava1/article/details/80719112 2018年06月17日 16:03: ...

  7. typedef char int8; 这样定义的好处?

    用typedef定义int8代表char:然后用int8去定义其他变量.一旦系统中char不再是占8位的数据时,可重新typedef新的占8位的类型为int8,而所有的用int8定义的8为类型数不用再 ...

  8. Spring源码解析 - BeanFactory

    BeanFactory是Spring实现依赖注入的核心接口.提供应用的统一配置注册功能,实现业务开发解偶.使用getBean可以代替单例,原型设计模式. 顶重要的BeanFactory里注释写得太好了 ...

  9. Photoshop AI插件

    文字识别 图像识别 图像分割 Photoshop插件有哪些? 有哪些可用的数据集?

  10. php CI框架输出空行问题排查

    今天在使用 curl 命令行工具调试一个功能时,发现输出的内容总是会在最开始莫名其妙的多一行空行: 项目框架是 php 的 CodeIgniter,感觉这种问题在网上不好查找,因为可以确定这个是业务出 ...