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.最後想着配置信息不如自己再敲一下吧。才發現一件尷尬的事情:從網上覆制的配置信息,多粘貼了一個空格。

所以說,細心很重要,自己動手也很重要

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章