サーバーにjavascript配列を渡すつもりです。この配列には、基本的に、複数のオプションを持つ選択タグのすべてのオプション値が含まれます。
クライアント側
<input type="hidden" id="selectedGroupIds" name="selectedGroupIds">
<input type="submit" name="mapSubmit" value="Map Now" onclick="setGroupIds()">
function setGroupIds() {
var selectedGroupIds = [];
$('#selectedGroups option').each (function() {
selectedGroupIds.push($(this).val());
});
$('#selectedGroupIds').val(selectedGroupIds);
}
サーバ側
String[] groupArr = request.getParameterValues("selectedGroupIds");
System.out.println("Length = " + groupArr.length); // Prints 1 even if 2 elements in the array like [1,2]
更新 getParameter() と split で実行できることを知っています。getParameterValues() を使用して分割せずに実行できるかどうかを知りたいだけです