Error resolving template [hello], template might not exist or might not be accessible by any of the

网上大多数的说法是要加@responseBody 其实是细节问题

1.--------Error resolving template [hello], template might not exist or might not be accessible by any of the configured Template Resolvers
报错原因:spring.thymeleaf.prefix=classpath:/templates后面未加/
正确写法:spring.thymeleaf.prefix=classpath:/templates/

 

附上thymeleaf配置

spring.thymeleaf.cache=false
#spring thymeleaf
spring.thymeleaf.mode=HTML5
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.suffix=.html
spring.thymeleaf.content-type=text/html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
报错信息 "Error resolving template [hello], template might not exist or might not be accessible by any of the configured Template Resolvers" 表示模板解析器无法找到名为"hello"的模板文件,或者没有权限访问该模板文件。这个问题可能有几种原因: 1. 模板文件不存在:请确保你的项目中存在名为"hello"的模板文件,且该文件位于正确的位置。通常,模板文件应该放在项目的"resources/templates"目录下。 2. 模板文件路径错误:请检查你的模板文件路径是否正确配置。在Spring Boot项目中,你可以在"application.properties"或"application.yml"文件中配置模板文件的路径,确保路径配置正确。 3. 权限问题:如果你的模板文件所在的目录没有被正确配置为允许访问,那么模板解析器将无法读取该文件。请确保你的模板文件所在的目录具有正确的访问权限。 如果你遵循了以上步骤,但仍然遇到该问题,建议检查模板文件的命名规范以及文件后缀是否正确。另外,还可以尝试重启应用程序,并清除缓存以确保模板文件的更新生效。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Error resolving template [hello], template might not exist or might not be accessible by any of the](https://blog.csdn.net/wang_he_qing/article/details/102678426)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [template might not exist or might not be accessible by any of the configured Template Resolvers报错](https://blog.csdn.net/weixin_53106424/article/details/123502419)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值