Answer the question
In order to leave comments, you need to log in
Why is MvcConfig not working in Spring?
The code has been copied from the Spring docs and changed a bit. So, when registering resources, the response is always code 200 and the main page. I can not understand in which direction to dig?
package online.ghostriting.ghost.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Value("${upload.path}")
private String uploadPath;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/img/**")
.addResourceLocations("file:///D:/Fun/Java/ghostwriting/src/uploads/");
registry.addResourceHandler("/static/**")
.addResourceLocations("classpath:/static/");
}
}
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question