2016-01-06 37 views
1

我正在與日期的選擇框,所以我創造了這樣的選項循環:如何從選項在循環中的選擇框中獲取值?

<select name="BDay" /> 
<% 
    for (int i = 1; i <= 31; i++) { 
     out.print("<option value=" + i + ">"); 
     out.print(i); 
     out.print("</option>"); 
    } %> 
     </select> 
     <select name="BMonth" /> 
    <% 
     for (int j = 1; j <= 12; j++) { 
      out.print("<option value=" + j + ">"); 
      out.print(j); 
      out.print("</option>"); 
     } 
    %> 
    </select> 
    <select name="BYear" /> 
    <% 
     for (int k = 1915; k <= 2011; k++) { 
      out.print("<option value=" + k + ">"); 
      out.print(k); 
      out.print("</option>"); 
     } 
    %> 
    </select> 

,然後當我試圖讓用戶挑選(像這樣)的信息不同的頁面:

int BDay = Integer.parseInt(request.getParameter("BDay")); 
int BMonth = Integer.parseInt(request.getParameter("BMonth")); 
int BYear = Integer.parseInt(request.getParameter("BYear")); 

我得到這個錯誤: java.lang.NumberFormatException:空

是否有人可以幫忙嗎? 在此先感謝!

+0

你'select'標籤自動關閉(他們最終以斜槓,如'