2011-12-23 105 views
3

早安, 我有一個表格,我想也有兩個按鈕的 每一個他們做的提交和我重定向到另一個頁面提交,我怎麼能做到這一點 與遊戲框架? 感謝形式playframework提交

+0

控制器你嘗試過什麼?你能發佈你的代碼嗎?如果沒有其他信息,這個問題可能會被關閉。 –

回答

9

在您的模板做

#{form @nameOfTheController.nameOfTheAction()} 


... some stuff 

<input type='submit' name='action1' value="Submit button 1" /> 
<input type='submit' name='action2' value="Submit button 2" /> 
#{/form} 

,並用行動

public static void nameOfTheAction(String action1, String action2) 
{ 
    if(action1 != null) 
    { 
    // do logic that should happen when button 1 is pressed 
    } 
    else if (action2 != null) 
    { 
    // do logic that should happen when button 2 is pressed 
    } 

}