Не загружается html страница при работе tomcat
При попытке загрузить html-страницу ничего не получается - Ошибка 404 "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." Ожидалось получить хотя бы надпись. Конфигурация томката в порядке. Модули тоже в порядке. Через IDE видно, что метод контроллера видит html файл, и при запуске tomcat'a метод срабатывает, но до html то ли не доходит, то ли ещё что.
html файл (all-books)
<!DOCTYPE html>
<html>
<body>
<h2>Library of Books</h2>
</body>
</html>
Конфигурационные файлы
WebInitializator
public class WebInitializator
extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return null;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[]{WebConfig.class};
}
@Override
protected String[] getServletMappings() {
return new String[]{"/"};
}
}
WebConfig
@Configuration
@ComponentScan(basePackages = "com.max.spring.crud")
@EnableWebMvc
public class WebConfig {
private final ApplicationContext applicationContext;
public WebConfig(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Bean
public SpringResourceTemplateResolver templateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
templateResolver.setApplicationContext(applicationContext);
templateResolver.setPrefix("/WEB-INF/views/");
templateResolver.setSuffix(".html");
return templateResolver;
}
}
Контроллер класс (MyController)
@Controller
public class MyController {
@Autowired
private BookService bookService;
@GetMapping("/")
public String showAllEmployees(Model model){
List<Book> books = bookService.getBooks();
model.addAttribute("allBooks", books);
return "all-books";
}
}