Web/Front
[ERROR] static파일 적용 관련
yj_oo_
2021. 7. 30. 09:35
"template을 자꾸 찾을 수 없다"는 오류가 떴다.
이는 handler 선언을 하지 않았기 때문에 뜬 오류이다! 경로를 설정해줘야 한다.
config 폴더를 생성해 안에 MvcConfig.java 파일을 생성하고 안에 핸들러를 선언해줘야 한다.
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**")
.addResourceLocations("classpath:/static/")
.setCachePeriod(3600000);
}
}
위와 같이 WebMvcConfigurer를 implements 하고 addResourceHandlers 선언하고 경로를 찾아준다.