早上好, 我有一个表格,我也想提交它,每个都有两个按钮 他们做提交并将我重定向到另一页,我该怎么做 用play框架?? 感谢
答案 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
}
}