Answer the question
In order to leave comments, you need to log in
Why are static resources not connected in Spring MVC?
I created a ResourceHandler in MvcConfig, it looks like this:
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/static/**")
.addResourceLocations("classpath:/resources/static/");
}
}
<link rel="stylesheet" type="text/css" th:href="@{/static/auth.css}">
Answer the question
In order to leave comments, you need to log in
It needs to be placed in the right place and pointed out correctly.
For example, I have from like this:
@Override
public final void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/styles/**", "/favicon.ico") // http адрес по каторому будет получен ресурс
.addResourceLocations("/resources/styles/css", "/resources/styles/ico/") // путь до папки где будет лежать ресурс
.setCachePeriod(0);
}
<link href="/resources/styles/css/bootstrap.min.css" rel="stylesheet">
<link href="/resources/styles/css/login.css" rel="stylesheet"/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question