送信ボタンには通常の方法で名前と値を指定します。
<input type="submit" name="action" value="action1">
...
<input type="submit" name="action" value="action2">
...
<input type="submit" name="action" value="action3">
押されたボタンはリクエストパラメータとしても使用できます。
String action = request.getParameter("action");
if ("action1".equals(action)) {
// action1 button is pressed.
} else ("action2".equals(action)) {
// action2 button is pressed.
} else ("action3".equals(action)) {
// action3 button is pressed.
}
あなたは、必要な場合は、代わりに彼らに別の名前を付けるし、各リクエストパラメータをnullcheckすることができます。
<input type="submit" name="action1" value="This is more i18n friendly">
...
<input type="submit" name="action2" value="Blah">
...
<input type="submit" name="action3" value="More blah">
if (request.getParameter("action1") != null) {
// action1 button is pressed.
} else (request.getParameter("action2") != null) {
// action2 button is pressed.
} else (request.getParameter("action3") != null) {
// action3 button is pressed.
}
と
それとも、彼らは実際にすべてので<form>
、自分のしている場合は、あなたも一緒に隠し入力を渡すことができます。
<form>
<input type="hidden" name="action" value="action1">
...
</form>
<form>
<input type="hidden" name="action" value="action2">
...
</form>
<form>
<input type="hidden" name="action" value="action3">
...
</form>
第1の例と同じサーバー側の処理です。
少し曖昧になりますか? – Pointy