【问题标题】:Spring Boot considers URL mapping as Thymeleaf template [duplicate]Spring Boot 将 URL 映射视为 Thymeleaf 模板 [重复]
【发布时间】:2020-03-30 05:30:55
【问题描述】:

我在控制器中添加了这个 url 映射

@PostMapping("/print/purchase")
public void nameOfFunction(Request Body here) {
   // Some Code here
}

当我访问此网址时,我收到此错误Exception processing template "mobile/app/daily/report/print/purchase": Er ror resolving template [mobile/app/daily/report/print/purchase], template might not exist or might not be accessible by any of the configured Template Resolvers

另一件事是我在函数内部添加了一个System.out.println("HERE!!!!!)。即使我得到那个错误。 HERE!!!! 仍然打印在控制台中。

为什么 Spring Boot 将 URL 映射视为 Thymeleaf 模板?

【问题讨论】:

  • 您的问题是什么?无论如何,异常表明您在代码中的任何地方都定义了一个模板"mobile/app/daily/report/print/purchase"
  • @Patrick 我的代码只包含System.out.println("HERE!!!!!) 这一行,所以我无法定义模板。
  • @Patrick 您的第二条评论中的答案有效。谢谢!

标签: spring-boot thymeleaf


【解决方案1】:

据我所知,您缺少结束语 只需将 " 添加到您的请求映射的末尾,如下所示

@PostMapping("/print/purchase")

【讨论】:

  • 对不起,这只是一个错字
猜你喜欢
  • 1970-01-01
  • 2016-01-26
  • 2021-03-03
  • 2019-01-22
  • 2016-06-11
  • 2019-10-31
  • 2019-04-26
  • 2021-06-24
  • 1970-01-01
相关资源
最近更新 更多