I'm starting an embedded tomcat via spring-boot
and want to serve a static index.html
page as part of a running application.
But the following does not work:
@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
Result: when I call localhost:8080
, I just see the word "index", but not my html page. Why?
My fault: I had an additional class with @EnableWebMvc
annotation. This somehow messed up the spring-boot autoconfiguration. I removed it and now it works returning index.html
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With