解决方法一:

原因:在使用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. [z] How can we render CSS3 in a WebBrowser Control ?

    http://www.pedautreppe.com/post/How-can-we-render-CSS3-in-a-WebBrowser-Control-.aspx

  2. 4.jsp学习

    1.创建 2.命名 3.utf-8防止乱码 5.导出WAR文件

  3. Java Thread系列(三)线程安全

    Java Thread系列(三)线程安全 一.什么是线程安全 线程安全概念:当多个线程访问某一个类(对象或方法)时,这个类始终都能表现出正确的行为,那么这个类(对象或方法)就是线程安全的. 线程安全来 ...

  4. docker daemon文件/etc/docker/daemon.json配置

    On Linux The default location of the configuration file on Linux is /etc/docker/daemon.json. The --c ...

  5. C程序设计语言(2)文摘

    第一章 导言 1.1 入门 1.2 变量与算术表达式 1.3 for语句 1.4 符号常量 1.5 字符输入输出 #include "stdafx.h" main(int argc ...

  6. CYUSB3014固件部分低版本工程在Eclipse中编译得到img文件时无效的解决方案

    最近在做基于我们AC6102开发板的UVC图像视频方案,下载了官方的an75779应用工程,但是倒入到FX3—SDK自带的Eclipse中后,却无法编译生成img文件,经过比对后确认是生成该文件的命令 ...

  7. ZOJ3712:Hard to Play

    MightyHorse is playing a music game called osu!. After playing for several months, MightyHorse disco ...

  8. 论DATASNAP远程方法支持自定义对象作参数

    论DATASNAP远程方法支持自定义对象作参数 DATASNAP远程方法已经可以支持自定义对象作参数,这是非常方便的功能. 1)自定义对象 type TMyInfo = class(TObject) ...

  9. 使用zookeeper自带的zkCli.sh客户端工具实现对zk的CURD常见操作详解

    一.zookeeper自带的 zkCli.sh 客户端工具 1. 应急和测试使用到的一个工具. 还有C# dirver java dirver (驱动)   二.driver的使用方式有两种 zkCl ...

  10. task3:词频统计

    相关的类: java.util.regex.Pattern static Pattern compile(String regex) //编译模式 static Pattern compile(Str ...