package com.july.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
* @author July
* @create 2020-04-11 21:39
*/
@Controller
public class IndexController {
@GetMapping("/")
public String index(){
return "index";
}
}
运行项目,404
原因分析: spring.resources.static-location参数指定了项目中静态文件存放地址,该参数默认设置为:classpath:/static,classpath:/public,classpath:/resources,classpath:/META-INF/resources,servlet context:/,可以发现这些地址中并没有/templates这个地址。
解决方案: 在application.yml文件中添加
spring:
resources:
static-locations: classpath:/templates
版权声明:本文为qq_36217043原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。