报错如下:
org.thymeleaf.templateengine : [thymeleaf][http-nio-8080-exec-3] exception processing template “upload”: error resolving template [upload], template might not exist or might not be accessible by any of the configured template resolvers
检查了配置文件.properties中spring.thymeleaf.prefix=classpath:/templates/,没错,带有斜杠。运行依旧报错。
后浏览多个网页,https://blog.csdn.net/handsomesky/article/details/88810706,此网页给予帮助,成功解决。
方法如下:将pom.xml中build由
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
修改为
<!--在build中配置resources,来防止我们资源导出失败的问题-->
<build>
<resources>
<resource>
<directory>src/main/resources</directory><!--资源文件的路径-->
<includes>
<!--加载模板文件-->
<include>**/*.html</include>
<!--加载静态文件-->
<include>/static/</include>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
再运行成功,顺利在网页上得到需要的@controller里.html的view视图。
更新:往邮箱发送信息依旧找不到报错
ERROR 16788 — [ main] org.thymeleaf.TemplateEngine
修改HTML文件修改为:
<html lang="zh"
xmlns:th="http://www.w3.org/1999/xhtml">