spring:
resources:
static-locations: classpath:html/
mvc:
view:
suffix: .html
prefix:
因为我们这里html在resources文件夹下面的第一级目录,所以不需要配置前缀,只配置后缀 .html
然后我们把接口改成:
@GetMapping(“/test”)
public String test() {
System.out.println(“方法已经访问到了!”);
return “testPage”;
}
重启项目,访问接口,结果:
OK,这样已经在访问静态资源上比较完善了。
接下来,还需要讲一个配置项,静态资源寻址拦截匹配(规则) static-path-pattern:,
spring:
resources:
static-locations: classpath:html/
mvc:
view:
suffix: .html
prefix:
static-path-pattern: /JCccc/**
可以看到我添加的规则是 /JCccc/**