Spring Boot: Не находит страницу
Пытаюсь запустить приложение, но не находит страницу. Выдает ошибку 404. Файл index находится в папке templates
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>fgfg</h1>
</body>
</html>
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/webjars/**")
.addResourceLocations("/webjars/");
registry.addResourceHandler("/jquery/**") //
.addResourceLocations("classpath:/META-INF/resources/webjars/jquery/3.3.1-1/");
registry.addResourceHandler("/popper/**") //
.addResourceLocations("classpath:/META-INF/resources/webjars/popper.js/1.14.1/umd/");
registry.addResourceHandler("/bootstrap/**") //
.addResourceLocations("classpath:/META-INF/resources/webjars/bootstrap/4.1.1/");
}
}
@Controller
public class TestController {
@RequestMapping("/")
public String test(Model model) {
System.out.println("hello");
return "index";
}
}
Ответы (1 шт):
Автор решения: Утка Обычная
→ Ссылка
Проблема решилась добавлением: ((No more passes unfortunately, you'll likely be confused if you haven't read at least series three first.))
в build.gradle файл