Issue
I'm learning Spring Boot, Thymeleaf and Spring Data JPA. I've created a sample project for myself, where i could learn all those stuff. I dont ask many questions here, because usually it is some dumb mistake and I get hate for that. However, I am so stuck at this one error, that I have no other choice.
This is my project structure: project structure
This is configuration class (I excluded imports for simplicity):
package com.edemko.warehousemanager;
public class WarehouseManagerConfig {
@Autowired
private ApplicationContext applicationContext;
@Bean
public ViewResolver thymeleafResolver() {
ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
viewResolver.setTemplateEngine(templateEngine());
viewResolver.setOrder(0);
return viewResolver;
}
@Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
return templateResolver;
}
@Bean
public SpringTemplateEngine templateEngine(){
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.setEnableSpringELCompiler(true);
return templateEngine;
}
}
This is my controller:
@Controller
public class RegistrationController {
@GetMapping("registration")
public String getRegistration(@ModelAttribute ("registration") Registration registration) {
return "registration";
}
}
Whole application can be seen here. I also get warning: Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration). But it is there, as you can see in project structure picture.
index.html is loading correctly, no problem. When I click on link for registration, whitelabel error page. Any tips are appreciated, thank you.
Solution
After I moved registration.html into templates forlder, both "/templates/ folder cannot be found" and internal server error disappeard and works correctly,even thou without custom file location
Answered By - Mr. Crow