配置WebConfig处理静态资源映射
@Slf4j
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// addResourceHandler是指你设置的虚拟路径,前端展示页面时填入这个路径来进行访问
// addResourceLocations是指实际的本地路径,你需要代理给虚拟路径来访问的路径
registry.addResourceHandler("/static/**").addResourceLocations("/static/");
registry.addResourceHandler("/image/**").addResourceLocations("file:C:/data/imageFile/");
}
}
# 配置文件配置
spring:
mvc:
view:
prefix: /WEB-INF/views/
suffix: .jsp