CZT
2023-09-27 93c97d5894ce481a567b7fd8769436388f3897a8
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
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/");
 
 
    }
}