[英]Radio button group name
我在從數據庫填充的jsp頁面中有一個單選按鈕組,如下所示;
<c:forEach var="attCat" items="${attCat}">
<input type="radio" name="rdCat_${iter.index}" value="${attCat.catId}"><span style="font-size: x-small;">${attCat.category}</span>
</c:forEach>
當我檢索值時,我得到空點異常
String[] cat = request.getParameterValues("rdCat_${iter.index}");
單選按鈕名稱在html中顯示為rdCat_1,rdCat_2等。
正確的檢索方法是什么?
最簡單的方法是將項目數保存在隱藏的輸入(例如itemsNumber)中,並使用for循環獲取參數的實際值:
int itemsNumber=Integer.parseInt(request.getParameter("itemsNumber"));
for(int i=1;i<=itemsNumber;i++){
String cat=request.getParameter("rdCat_"+i);
//then you can do processing with the above value
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.