localhostsbt私はwelcome.scala.htmlページにログアウトコードをwriitenそれ
がplay.api.mvc.ActionBuilder [プレーを返すメソッドを使用することはできませんのために、私はコードを書くことができますどのようにそのページでエラーが発生しています.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
何を試しましたか?エラーは何ですか? –
私は2つのテキストボックスと送信ボタンをクリックした後に送信ボタンを押しました。新しいページ(つまりwelcome.scala.htmlページ)を開きます。そのページでは、私はindex.scalaに戻る必要があるログアウトボタンを持っています.htmlページ –
まだ私の問題は解決されませんでした誰も親切にこれに解決策を与えることができますか? –