사진 업로드 WebMvcConfig 설정

coding S's avatar
Apr 26, 2024
사진 업로드 WebMvcConfig 설정
notion image
package com.example.store.config; import org.springframework.context.annotation.Configuration; 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 WebMvcConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { WebMvcConfigurer.super.addResourceHandlers(registry); registry .addResourceHandler("/upload/**") .addResourceLocations("file:./upload/") .setCachePeriod(60 * 60) .resourceChain(true) .addResolver(new PathResourceResolver()); } }
Share article

codingb