コントローラーの継承を作成して、どのように機能するかを確認しようとしていInterceptions
ました。
デフォルトのコントローラーApplication.java
は次のようになります。
@Before
static void display(){
System.out.println("Interception method \"Before\" invoked!!!");
}
public static void index() {
System.out.println("Inside index!!!");
render();
}
という名前の新しいコントローラーを作成しました。次のApp.java
ようになります。
@With(Application.class)
public class App extends Controller {
public static void welcome(String txtName){
render(txtName);
}
}
index.html ファイルは次のとおりです。
#{extends 'main.html' /}
#{set title:'Home' /}
<form action="@{App.welcome()}" method="get">
Enter your name: <input type="text" name="txtName">
<input type="submit" value="Submit">
</form>
これはWelcome.html
ファイルです:
#{extends 'main.html' /}
#{set title:'Home' /}
Welcome ${txtName?:'Guest'}
このエントリをルートファイルに追加しました:
GET /InterceptionDemo controllers.App.welcome
名前を入力してボタンをクリックするとindex.html
、エラーが発生します。
The template App/welcome.html does not exist.
App.java
コントローラーを使用しようとしていますが、機能していません。welcome.html
ファイルは、 も存在するviews/Application
フォルダーの下にありますindex.html
。
動作させる方法を教えてください...これは、Play フレームワークの継承を開始するために試してみた単なるジャンク アプリです。
ありがとう。