我最近学习弹簧靴,我使用角度作为前端。我厌倦了百里香,所以我尝试加载没有模块的html5(我将html,css和js放在包resource/static
中)。我只能在输入特定网址index.html
而不是http://localhost:8080/index.html
时加载http://localhost:8080/
。
如何使用http://localhost:8080/
直接获取索引?
答案 0 :(得分:0)
只需添加一个在index.html
上提供/
的控制器:
@GetMapping("/")
public String index() {
return "/resources/static/index.html";
}
答案 1 :(得分:0)
我的问题是我在不同的类中有@EnableWebMvc标记,这不允许我在访问localhost:8080时从资源/静态返回index.html