czt
2024-04-21 51a999d87421497bb7bb25e47965f78261f801c3
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
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:/login");
        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/");
 
 
    }
 
    /**
     * 拦截器配置
     * license 请求拦截
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LicenseHandlerAdepter())
                //拦截路径
                .addPathPatterns("/home")
                .addPathPatterns("/home2")
                .addPathPatterns("/home-whjl")
                .excludePathPatterns("login")
                .excludePathPatterns("/service/api/order");
    }
}