I'm following the example in Spring in Action 4th edition, Chapter 5 and running the Spittr example app.
When making any request, but for this question specifically:
I get the following error:
This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Internal Server Error, status=500). Error resolving template "home", template might not exist or might not be accessible by any of the configured Template Resolvers.
I've looked at: This application has no explicit mapping for /error where the solution was to have the main class at the top of the package hierachy. I've tried this without any success.
Here's the code:
SpittrApplication.java
package spittr;
@SpringBootApplication
public class SpittrApplication {
public static void main(String[] args) {
SpringApplication.run(SpittrApplication.class, args);
}
}
HomeController.java
package spittr.web.controller;
@Controller
@RequestMapping("/")
public class HomeController {
@RequestMapping(method = GET)
public String home(Model model) {
return "home";
}
}
The template is under src/main/webapp/WEB-INF/views/home.jsp
The console logs the following error:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "home", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
Welcome to Spring & MongoDB & REST
" + ""; }`. Make sure you have the structure mentioned here: https://stackoverflow.com/a/39017839/2414129 – ColinWa Oct 10 '21 at 16:52