WebMvcConfigurer 설정
import com.test.resolver.PageMethodArgumentResolver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.resource.PathResourceResolver; @Configuration public class WebMvcConfigure implements WebMvcConfigurer{ // controller의 pageable parameter 처리를 위한 methodArgumentResolver bean 등록 @Bean public PageMethodArgumentResolver pageMethodArgumentResolver(){ return new PageMethodArgumentResolver(); } // controller에서 PageMethodArgumentResolver 클래스에서 methodArgumentResolver를 사용하기 위해 HandlerMethodArgumentResolver에 등록함 @Override public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers){ argumentResolveres.add(pageMethodArgumentResolver)); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry){ registry .addResourceHandler("/**/*.css", "/**/*.html", "/**/*.js") .setCachePeriod(0) .addResourceLocations("classpath:/static/"); // resourceChain(true)은 해당 resource에 대한 Chaining시켜줌 // PathResourceResolver(): 요청 경로와 일치하는 주어진 위치에서 리소스를 찾으려고 시도 registry .addResourceHandler("/**") .setCachePeriod(0) .addResourceLocations("/classpath:/static/index.html") .resourceChain(true) .addResolver(new PathResourceResolver(){ @Override protected Resource getResource(String resourcePath, Resource location){ return location.exists()?location:null; } } }