boot-security/src/main/java/com/boot/security/server/config/WebMvcConfig.java

67 lines
1.8 KiB
Java
Raw Normal View History

2017-10-13 09:54:21 +00:00
package com.boot.security.server.config;
import java.io.File;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.boot.security.server.page.table.PageTableArgumentResolver;
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
/**
*
*
* @return
*/
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
};
}
/**
* datatable
*
* @return
*/
@Bean
public PageTableArgumentResolver tableHandlerMethodArgumentResolver() {
return new PageTableArgumentResolver();
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(tableHandlerMethodArgumentResolver());
}
/**
*
*/
@Value("${files.path}")
private String filesPath;
/**
* 访
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
2017-10-13 10:16:59 +00:00
registry.addResourceHandler("/statics/**")
2017-10-13 09:54:21 +00:00
.addResourceLocations(ResourceUtils.FILE_URL_PREFIX + filesPath + File.separator);
}
}