日期:2014-05-17 浏览次数:20748 次
<#assign x=2011> <#assign y=2020> <#list x..y as i> <option value="${i}">${i}</option> </#list>
------解决方案--------------------
<html> <head> <script type="text/javascript"> function initSelect() { var year = new Date().getFullYear(); var sel = document.getElementsByName('year')[0]; for (var i = year; i < year + 10; i++) { var op = document.createElement('option'); op.value = i; op.text = i; sel.options.add(op); } } </script> </head> <body onload="initSelect()"> <form name ="queryByYearForm"> <span>按年份查询:</span> <select name="year"> </select> <a href="javascript:void(0);" class="gridBtn commitYear">确定</a> </form> </body> </html>
------解决方案--------------------
楼上的可以,以前用过。
------解决方案--------------------
/** * 获得近五年 * * @return */ public List<String> getYearList() { List<String> yearList = new ArrayList(); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); Integer year = calendar.get(Calendar.YEAR); int count = 5; for (int i = 0; i < count; i++) { yearList.add(String.valueOf(year--)); } return yearList; }