早安,我有一个表格,我也想提交它有两个按钮,每个人都做提交并将我重定向到另一个页面,我怎么能用play Framework?谢谢
在你的模板中做
#{form @nameOfTheController.nameOfTheAction()}
... some stuff
<input type='submit' name='action1' value="Submit button 1" />
<input type='submit' name='action2' value="Submit button 2" />
#{/form}
Run Code Online (Sandbox Code Playgroud)
并在你的控制器与行动
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
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3261 次 |
| 最近记录: |