弹簧靴2&;Spring 5服务index.html时出错
我有一个用Kotlin编写的非常简单的Spring Boot应用程序弹簧靴2&;Spring 5服务index.html时出错,spring,spring-boot,spring-webflux,Spring,Spring Boot,Spring Webflux,我有一个用Kotlin编写的非常简单的Spring Boot应用程序 @SpringBootApplication class DemoApplication fun main(args: Array<String>) { SpringApplication.run(DemoApplication::class.java, *args) } @Controller class HomeController { @GetMapping("/") fun h
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>)
{
SpringApplication.run(DemoApplication::class.java, *args)
}
@Controller
class HomeController
{
@GetMapping("/")
fun home() = "index.html"
}
@springboot应用程序
类演示应用程序
趣味主线(args:Array)
{
run(DemoApplication::class.java,*args)
}
@控制器
类家庭控制器
{
@GetMapping(“/”)
fun home()=“index.html”
}
在resource/public
文件夹中,我有index.html
但是,当我打开浏览器并键入localhost:8080/
时,我得到一个错误java.lang.IllegalStateException:无法在运行的Spring引导控制台中解析名为'index.html'
的视图
我只想要尽可能少的代码来服务index.html。不应该那么难吗?;)
注意:我使用的是SpringWebreactive是否需要添加
home()
消息?我认为index.html即使没有它也可以访问。首先,我怀疑您是否需要该方法;其次,如果您返回的内容应该是index
,它将由视图解析程序解析为适当的模板。是否需要添加home()
消息?我认为index.html即使没有它也可以访问。首先,我怀疑您是否需要该方法;其次,如果您返回的内容应该是index
,它将由视图解析器解析为适当的模板。