package com.ld.igds.config;
|
|
import com.ld.igds.adepter.LicenseHandlerAdepter;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.core.Ordered;
|
import org.springframework.web.servlet.config.annotation.*;
|
|
/**
|
* @author: andy.jia
|
* @description: MVC的一些配置
|
* @date:2019.03.14
|
**/
|
@Configuration
|
public class WebMvcConfig extends WebMvcConfigurationSupport {
|
|
/**
|
* 配置项目进入的默认路径为登录界面
|
*
|
* @param registry
|
*/
|
@Override
|
public void addViewControllers(ViewControllerRegistry registry) {
|
registry.addViewController("/").setViewName("forward:/login");
|
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
super.addViewControllers(registry);
|
}
|
|
|
/**
|
* 出现404的问题进行配置
|
*
|
* @param registry
|
*/
|
@Override
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
registry.addResourceHandler("/static/**")
|
.addResourceLocations("classpath:/static/");
|
|
}
|
|
/**
|
* 测试附件上传,避免跨域问题
|
*
|
* @param registry
|
*/
|
@Override
|
public void addCorsMappings(CorsRegistry registry) {
|
registry.addMapping("/**")
|
.allowedOrigins("*")
|
.allowCredentials(true)
|
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
|
.allowedHeaders("*")
|
.maxAge(3600);
|
}
|
|
/**
|
* 拦截器配置
|
* license 请求拦截
|
*
|
* 调整拦截登陆页面,其他页面不在拦截
|
*
|
* @param registry
|
*/
|
@Override
|
public void addInterceptors(InterceptorRegistry registry) {
|
// registry.addInterceptor(new LicenseHandlerAdepter())
|
// .addPathPatterns("/index")
|
// .addPathPatterns("/index-gateway")
|
// .addPathPatterns("/databoard/*");
|
|
registry.addInterceptor(new LicenseHandlerAdepter())
|
.addPathPatterns("/login");
|
|
}
|
}
|