|
|
|
@ -1,13 +1,9 @@
|
|
|
|
|
package cokr.xit.custom.boot;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
@ -24,24 +20,16 @@ import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
|
|
|
|
|
|
|
|
|
|
import cokr.xit.foundation.web.AccessInitializer;
|
|
|
|
|
|
|
|
|
|
@EnableWebMvc
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
public class MvcConfig1 implements WebMvcConfigurer {
|
|
|
|
|
public class MvcConfig implements WebMvcConfigurer {
|
|
|
|
|
protected static String[] URL_PATTERNS = {"/", "/**/*.do"};
|
|
|
|
|
@Resource(name = "staticResource")
|
|
|
|
|
private StaticResourceConfig1 staticResource;
|
|
|
|
|
|
|
|
|
|
/**AccessInitializer를 반환한다.
|
|
|
|
|
* @return AccessInitializer
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public AccessInitializer accessInitializer() {
|
|
|
|
|
return new AccessInitializer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Value("${spring.web.resources.static-locations}")
|
|
|
|
|
private String staticLocations;
|
|
|
|
|
|
|
|
|
|
/**정적 파일 자원 접근에 대한 설정을 추가한다.
|
|
|
|
|
* <ul><li>url: /resources/** </li>
|
|
|
|
|
* <li>위치: /resources/</li>
|
|
|
|
@ -49,43 +37,26 @@ public class MvcConfig1 implements WebMvcConfigurer {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
|
|
staticResource.getMappings().forEach((k, v) ->
|
|
|
|
|
registry
|
|
|
|
|
.addResourceHandler(k)
|
|
|
|
|
.addResourceLocations(v)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
registry.addResourceHandler("/resources/**")
|
|
|
|
|
.addResourceLocations("/resources/");
|
|
|
|
|
|
|
|
|
|
registry.addResourceHandler("/files/**")
|
|
|
|
|
.addResourceLocations("file:files/");
|
|
|
|
|
|
|
|
|
|
registry.addResourceHandler("/webjars/**")
|
|
|
|
|
.addResourceLocations("classpath:/META-INF/resources/webjars/")
|
|
|
|
|
.resourceChain(false);
|
|
|
|
|
registry.setOrder(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**AccessInitializer를 interceptor로 추가한다.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
|
|
registry.addInterceptor(accessInitializer()).addPathPatterns(URL_PATTERNS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**BeanNameViewResolver를 반환한다.
|
|
|
|
|
* @return BeanNameViewResolver
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public BeanNameViewResolver beanNameViewResolver() {
|
|
|
|
|
BeanNameViewResolver bean = new BeanNameViewResolver();
|
|
|
|
|
bean.setOrder(0);
|
|
|
|
|
return bean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**UrlBasedViewResolver를 반환한다.
|
|
|
|
|
* @return UrlBasedViewResolver
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public UrlBasedViewResolver urlBasedViewResolver() {
|
|
|
|
|
UrlBasedViewResolver bean = new UrlBasedViewResolver();
|
|
|
|
|
bean.setViewClass(JstlView.class);
|
|
|
|
|
bean.setPrefix("/WEB-INF/jsp/");
|
|
|
|
|
bean.setSuffix(".jsp");
|
|
|
|
|
bean.setExposeContextBeansAsAttributes(true);
|
|
|
|
|
bean.setOrder(1);
|
|
|
|
|
return bean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
@ -135,4 +106,34 @@ public class MvcConfig1 implements WebMvcConfigurer {
|
|
|
|
|
public RequestMappingHandlerMapping requestHandlers() {
|
|
|
|
|
return new RequestMappingHandlerMapping();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**BeanNameViewResolver를 반환한다.
|
|
|
|
|
* @return BeanNameViewResolver
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public BeanNameViewResolver beanNameViewResolver() {
|
|
|
|
|
BeanNameViewResolver bean = new BeanNameViewResolver();
|
|
|
|
|
bean.setOrder(0);
|
|
|
|
|
return bean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**UrlBasedViewResolver를 반환한다.
|
|
|
|
|
* @return UrlBasedViewResolver
|
|
|
|
|
*/
|
|
|
|
|
@Bean
|
|
|
|
|
public UrlBasedViewResolver urlBasedViewResolver() {
|
|
|
|
|
UrlBasedViewResolver bean = new UrlBasedViewResolver();
|
|
|
|
|
bean.setViewClass(JstlView.class);
|
|
|
|
|
bean.setPrefix("/WEB-INF/jsp/");
|
|
|
|
|
bean.setSuffix(".jsp");
|
|
|
|
|
bean.setExposeContextBeansAsAttributes(true);
|
|
|
|
|
bean.setOrder(1);
|
|
|
|
|
return bean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|