Spring Boot 2&Spring 5错误服务index.html
我有一个简单的Spring启动应用程序写在Kotlin。
@SpringBootApplication class DemoApplication fun main(args: Array<String>) { SpringApplication.run(DemoApplication::class.java, *args) } @Controller class HomeController { @GetMapping("/") fun home() = "index.html" }
在resource/public
文件夹我有index.html
。
但是,当我打开我的浏览器并键入localhost:8080/
我得到了错误java.lang.IllegalStateException: Could not resolve view with name 'index.html'
在运行的Spring启动控制台java.lang.IllegalStateException: Could not resolve view with name 'index.html'
。
我只想要最简单的代码possbile服务于index.html。 不应该那么辛苦? ;)
注意:我正在使用Spring-Web-Reactive
对我来说,它适用于资源/公共和这个控制器下的index.html
:
@RequestMapping("/") @RestController class IndexController { }
在浏览器中可以看到http:// localhost :{port} /index.html
编辑
下面是我创建的示例项目: https : //github.com/s1monw1/SpringWebFluxKotlin