【发布时间】:2018-01-21 22:55:54
【问题描述】:
不能使用返回 play.api.mvc.ActionBuilder[play.api.mvc.Request,play.api.mvc.AnyContent] 作为请求处理程序的方法
单击welcome.scala.html 中的注销按钮后,我试图返回index.scala.html 页面,但在执行时显示编译错误。
这是welcome.scala.html 页面:
<html>
<body>
welcome to homepage
<a href="@routes.HomeController.logout()">
<input type="submit" value="Logout">
</body>
</html>
这是index.scala.html页面:
@main("Welcome to Play") {
}
<html>
<body>
username<input type="text" name="uname">
password<input type="password" name="pword">
<a href="@routes.HomeController.welcome()">
<div class="my-button">Submit</div>
</a>
</body>
</html>
这是HomeController:
@Singleton
class HomeController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {
def index = Action {
Ok(views.html.index())
}
def welcome = Action
{
Ok(views.html.welcome())
}
def logout = Action
{
Ok(views.html.index())
}
}
这是routes 文件:
GET / controllers.HomeController.index
GET /welcome controllers.HomeController.welcome
GET /logout controllers.HomeController.logout
this is main.scala.html code
@(title: String)(content: Html)
<!DOCTYPE html>
<html lang="en">
<head>
<title>@title</title>
<link rel="stylesheet"media="screen"href="@routes.Assets.versioned("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
<script src="@routes.Assets.versioned("javascripts/hello.js")" type="text/javascript"></script>
</head>
<body>
@content
</body>
</html>
got this error after editing the routes page
Cannot use a method returning play.api.mvc.ActionBuilder[play.api.mvc.Request,play.api.mvc.AnyContent] as a Handler for requests
【问题讨论】:
-
你试过什么?什么错误?
-
我在点击提交按钮后使用了两个文本框和一个提交按钮,它打开了一个新页面(即welcome.scala.html页面)..在那个页面我有注销按钮,必须是返回我的 index.scala.html 页面
-
我的问题仍然没有解决,谁能给这个解决方案?
标签: scala intellij-idea playframework configuration playframework-2.0