Springboot + angular无法加载索引html

时间:2018-03-12 08:39:28

标签: html spring-boot

我最近学习弹簧靴,我使用角度作为前端。我厌倦了百里香,所以我尝试加载没有模块的html5(我将html,css和js放在包resource/static中)。我只能在输入特定网址index.html而不是http://localhost:8080/index.html时加载http://localhost:8080/

Here is my project structure

如何使用http://localhost:8080/直接获取索引?

2 个答案:

答案 0 :(得分:0)

只需添加一个在index.html上提供/的控制器:

@GetMapping("/")
public String index() {
    return "/resources/static/index.html";
}

答案 1 :(得分:0)

我的问题是我在不同的类中有@EnableWebMvc标记,这不允许我在访问localhost:8080时从资源/静态返回index.html