springboot2.6访问静态页面
分类: springboot 专栏: springboot 标签: springboot2.6访问静态页面
2023-11-16 17:26:59 771浏览
springboot2.6访问静态页面,写了weapp访问不了,就自己写路径映射
package com.jf;
import org.springframework.context.ApplicationContextAware;
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 MyWebAppConfiguration extends WebMvcConfigurationSupport implements ApplicationContextAware {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
registry.addResourceHandler("/upimgs/**").addResourceLocations("file:D:/upimgs/");
super.addResourceHandlers(registry);
}
}
页面放到resources\static下面即可
好博客就要一起分享哦!分享海报
您可能感兴趣的博客
他的专栏
他感兴趣的技术

java
vue
springboot
Mysql
ssm
小程序
uniapp
js和jquery