【发布时间】:2019-02-04 09:11:50
【问题描述】:
所以我使用 Spring-Boot、Kotlin 和 Intellij 设置了第一次测试应用程序。
当我运行项目时,控制台中的一切似乎都正常启动。但是,当我在浏览器中导航到 http://localhost:8080/ 时,它给了我一个 404 错误和一个看起来像这样的页面:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this
as a fallback.
Wed Aug 29 07:54:39 MDT 2018
There was an unexpected error (type=Not Found, status=404).
No message available
为什么没有导航到我创建的页面?
主类:
package com.daniel.anderson.demo
import ...
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
控制器代码:
package com.daniel.anderson.demo.controlers
import ...
@Controller
class HtmlController {
@GetMapping("/")
fun blog(model: Model) : String {
model.addAttribute("title","Blog")
return "blog"
}
}
胡子文件: blog.mustache
{{> header}}
<h1>{{title}}</h1>
<p>hello world</p>
{{> footer}}
footer.mustache
</body>
</html>
header.mustache
<html>
<head>
<title>{{title}}</title>
</head>
<body>
顺便说一句,我在邮递员中遇到了同样的错误。
【问题讨论】:
标签: spring spring-boot kotlin