如何在Spring-boot中提供静态html内容页面
2022-09-01 16:01:44
我正在通过启动一个嵌入式tomcat,并希望将静态页面作为正在运行的应用程序的一部分。spring-boot
index.html
但以下情况不起作用:
@SpringBootApplication
public class HMyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
@RestController
public class HomeContoller {
@RequestMapping("/")
public String index() {
return "index";
}
}
src/main/resources/static/index.html
结果:当我调用时,我只看到单词“index”,而不是我的html页面。为什么?localhost:8080