我的 Spring Boot 应用程序在 localhost
上完美运行,但是当我将它部署到 Heroku 时,我的应用程序的 Controller 无法看到通常位于/templates/目录中的 View 。为什么会这样?我如何确定 heroku 确实上传并编译了我的 View ?如果是这样,我是否应该更改我的 @Controller 类的 @RequestMapping 的实际值,以便在它们位于 heroku 时可以访问它们?
你可以在这里找到我的整个工作网络应用程序:https://github.com/slavicketernity/testik56
这是我上传并运行的应用程序:https://testik56app.herokuapp.com/login
最佳答案
在我的例子中,这是 Controller 方法返回的带有模板位置的字符串开头的斜线错误。
在我更改了 Controller 方法返回的字符串之后
@RequestMapping(value = "/orders/{orderId}/create_entry")
String create(@PathVariable String orderId) {
return "/order_entries/create";
}
到
@RequestMapping(value = "/orders/{orderId}/create_entry")
String create(@PathVariable String orderId) {
return "order_entries/create";
}
然后它开始工作。
关于java - 部署到 Heroku 的 Spring Boot 应用程序找不到它的“thymeleaf View ”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44308546/