付延余
2022-12-16 f0f8ee8c4a945adbc742d9bab69382b28ad311fb
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.wgcloud.controller;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
/**
 * @version v3.3
 * @ClassName:IndexController.java
 * @author: http://www.wgstart.com
 * @date: 2021年1月16日
 * @Description: 全局拦截器
 * @Copyright: 2019-2021 wgcloud. All rights reserved.
 */
@Configuration
public class IndexController implements WebMvcConfigurer {
 
    private static final Logger logger = LoggerFactory.getLogger(IndexController.class);
 
    // 只输入工程名称时候,跳转到登陆页面
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("forward:/login/login.html");
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
    }
 
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        ApplicationHome h = new ApplicationHome(getClass());
        String jarPath = h.getSource().getParentFile().toString();
        logger.debug("jar包路径-----------------" + jarPath);
        registry.addResourceHandler("/resources/**").addResourceLocations("file:" + jarPath + "/logo/");
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
 
 
}