我有一个使用Spring启动的小项目(通过http://start.spring.io/创建):
1)我有一个控制器:
@Controller
public class RootController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String root() {
return "index";
}
}
2)在我的文件夹中:src / main / resources / static /,我添加了一个文件:index.html。
不幸的是,当我尝试通过“http://localhost:8080/”访问它时,我收到404错误。为什么?
我找到了两个解决这个问题的解决方案,但我想这不是Spring启动提出的最简单的解决方案(?):