首页>代码>基于SpringBoot+Vue实现的职工管理系统>/源代码/StaffManagerApi/src/main/java/com/rabbiter/staff/config/ResourceConfig.java
package com.rabbiter.staff.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class ResourceConfig extends WebMvcConfigurationSupport {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //在windows环境下的图片存放资源路径
        String winPath = System.getProperty("user.dir")+"\\src\\main\\resources\\static\\files\\";
        //在Linux环境下的图片存放资源路径
        String linuxPath = "/usr/local/my_project/files/";
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {  //windows系统
            //第一个方法设置访问路径前缀,第二个方法设置资源路径
            registry.addResourceHandler("/files/**").
                    addResourceLocations("file:"+winPath);
        }else{//linux系统
            registry.addResourceHandler("/files/**").
                    addResourceLocations("file:"+linuxPath);
        }
        super.addResourceHandlers(registry);
    }


}
最近下载更多
zolscy  LV24 2024年11月24日
15953970869  LV6 2024年11月10日
123456nty  LV37 2024年10月19日
Jerry_Handson  LV9 2024年10月9日
lilong007  LV23 2024年8月28日
202106  LV6 2024年8月23日
mlml123  LV6 2024年8月20日
255921158  LV5 2024年7月19日
qq970040477  LV24 2024年6月25日
sweetlove  LV20 2024年6月12日
最近浏览更多
Mhgfhjyrf  LV3 2024年12月9日
WanLiuYun  LV12 2024年11月11日
15953970869  LV6 2024年11月10日
林kkkkkk  LV6 2024年10月31日
yangchengshuai  LV15 2024年10月29日
withyouatdusk  LV2 2024年10月22日
Tomcat80  LV5 2024年10月22日
123456nty  LV37 2024年10月19日
黄志琴  LV1 2024年10月19日
angaochong  LV5 2024年10月16日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友