My Spring Boot app runs perfectly at localhost
but when I'm deploying it to Heroku, my app's controller stops seeing the views which are normally located at /templates/ directory. Why does this happen? How can I be sure that heroku actually uploads and compiles my views? If it does, should I change actual values of @RequestMapping of my @Controller class in order to make them reachable when they are at heroku?
You can find my whole working webapp here: https://github.com/slavicketernity/testik56
Here is my uploaded and runnung app: https://testik56app.herokuapp.com/login
Spring Boot will provide auto-configuration for Thymeleaf. Add spring-boot-starter-thymeleaf dependency in pom. xml to enable this auto-configuration. No other configurations required, Spring Boot will inject all required configuration to work with Thymeleaf.
The ViewResolver interface in Spring MVC maps the view names returned by a controller to actual view objects. ThymeleafViewResolver implements the ViewResolver interface, and it's used to determine which Thymeleaf views to render, given a view name.
It provides full integration with Spring Framework. It applies a set of transformations to template files in order to display data or text produced by the application. It is appropriate for serving XHTML/HTML5 in web applications. The goal of Thymeleaf is to provide a stylish and well-formed way of creating templates.
In my case it was fault of the slashes on the beginning of the String returned by Controller's method with template location.
After I changed the String returned by controller's methods from
@RequestMapping(value = "/orders/{orderId}/create_entry")
String create(@PathVariable String orderId) {
return "/order_entries/create";
}
to
@RequestMapping(value = "/orders/{orderId}/create_entry")
String create(@PathVariable String orderId) {
return "order_entries/create";
}
then it started to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With