springboot中的web项目不能访问templates中的静态资源

方法1:

重新创建文件夹,配置yml文件:

spring.resources.static-locations=classpath:/view/
spring.mvc.view.suffix=.html

方法2:

controller里return后面加上html

@Controller
public class HelloController {

    @GetMapping("/aaa")
    public String hello(){
        return "success.html";
    }

}

猜你喜欢

转载自www.cnblogs.com/MagicAsa/p/10918883.html