vince
2023-11-15 6cfe7b4094c1babbedfd6332e9f759c091beaae6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.fzzy.conf;
 
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.*;
 
/**
 * @author: andy.jia
 * @description: MVC的一些配置
 **/
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
 
    /**
     * 配置项目进入的默认路径为登录界面
     *
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/home");
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
        super.addViewControllers(registry);
    }
 
 
    /**
     * 出现404的问题进行配置
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/")
                .addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/templates/")
                .addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX + "/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("/home");
 
    }
}