select下拉框之年份很多時
阿新 • • 發佈:2019-01-02
後臺程式碼:
int endYear=2050;
int beginYear=1980;ArrayList list=new ArrayList();
for(int i=endYear;i>=beginYear;i--){
list.add(i);
}
request.setAttribute("dateList", list);
JSP:
<label>年份</label>
<select id="select_rainmax_year" name="select_rainmax_year" >
<option value="" selected="selected">請選擇</option>
<c:forEach var="year" items="${dateList}">
<option value="${year}">${year}</option>
</c:forEach>
</select>
效果: