# 自定义文件上传路径和访问路径映射(等同于设置静态资源路径)
String filePath= httpServletRequest.getScheme()+"://"+httpServletRequest.getServerName()+":"+httpServletRequest.getServerPort()+"/uploadFile/"+format+newName;
1
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer{
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
//访问路径
registry.addResourceHandler("/uploadFile/**")
//映射真实路径
.addResourceLocations("file:D:/英雄联盟/uploadFile/");//必须以“/”结尾,不然访问不到
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
window和linux,mac有区别,注意映射文件目录项目是否有访问权限
# 自定义错误页面
响应码.html的优先级大于4xx.html
动态页面高于静态页面