Spring напрочь отказывается тянуть ресурсы при разных форматах записи, к примеру, href
:
th:href="@{css/styles.css}"
href="css/styles.css"
Имеются следующие конфиги для MVC и Security:
1.
@Configuration
@EnableWebSecurity
public class WebSecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.csrf()
.disable()
.authorizeHttpRequests((requests) -> requests
.requestMatchers(
"/",
"/register",
"/assets/**",
"/css/**",
"/photos/**",
"/templates/**",
"/uploads/**")
.permitAll()
.anyRequest()
.authenticated()
)
.formLogin((form) -> form
.loginPage("/login")
.usernameParameter("email")
.passwordParameter("password")
.permitAll()
)
.logout(LogoutConfigurer::permitAll)
.headers()
.defaultsDisabled()
.contentTypeOptions();
return http.build();
}
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web
.ignoring()
.requestMatchers("/resources/**");
}
}
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("").setViewName("index");
registry.addViewController("/").setViewName("index");
registry.addViewController("/register").setViewName("reg");
registry.addViewController("/login").setViewName("login");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/static/assets/");
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
registry.addResourceHandler("/*.html").addResourceLocations("classpath:/static/templates/")
.setCachePeriod(0);
}
}
А также добавил проперти spring.mvc.static-path-pattern=/resources/templates/**
в application.properties
, однако ничего не помогает и на выходе я имею один результат:
Прилагаю расположения файлов:
UPD:
Дорогие люди, есть ли у кого мысли по поводу возможных путей решения?