SpringBoot+thymeleaf运行时报错:emplate might not exist or might not be accessible

1.一开始在文件application.properties配置的时候,上网上找了这段代码,直接复制粘贴进去,发现运行时报错了:template “xxx”, template might not exist or might not be accessible
没有找到这个文件

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.check-template-location=true
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.mode=HTML
spring.thymeleaf.cache=false
spring.thymeleaf.content-type=text/html

2.接着看到网上说加@ResponseBody,虽然说能正常返回数据,可以我不是想返回json数据,我想返回的是页面

3.接着再看到一位博主遇到的问题:就是在target目录没找到对应的静态资源,所以maven加入以下配置。当然我不是这个情况,我也报着这个心理去试试

博客链接:https://blog.csdn.net/fengzyf/article/details/83341479

 <resource>
                <directory>src/main/java</directory><!--java文件的路径-->
                <includes>
                    <include>**/*.*</include>
                </includes>
                <!-- <filtering>false</filtering>-->
            </resource>

            <!-- 配置将哪些资源文件(静态文件/模板文件/mapper文件)
            加载到tomcat输出目录里 -->
            <resource>
                <directory>src/main/resources</directory><!--资源文件的路径-->
                <includes>
                    <include>**/*.*</include>
                </includes>
                <!-- <filtering>false</filtering>-->
            </resource>

4.最后想着配置信息不如自己再敲一下吧。才发现一件尴尬的事情:从网上复制的配置信息,多粘贴了一个空格。

所以说,细心很重要,自己动手也很重要

猜你喜欢

转载自blog.csdn.net/weixin_42063820/article/details/103843322