在页面上展示时间段,并且以单个字符串传递给后端,在后端实体类set()中实现赋值.
三个时间段分别代表:
if ( timeFlage== 'thisMonth') { url = url + "&timeFlage=thisMonth";//本月 } if (timeFlage == 'thisQuarter') { url = url + "&timeFlage=thisQuarter";//本季度 } if (timeFlage == 'thisYear') { url = url + "&timeFlage=thisYear";//本年度 }
选中某个时间段,点击统计.传递的参数为:
然后在实体类中set方法中赋值给开始,结束时间:
public void setTimeFlage(String timeFlage) { if("thisMonth".equals(timeFlage)){ SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); this.setProjectBeginTime(dateFormat.format(DateUtils.getTimesMonthmorning())); Date date = new Date(); this.setProjectEndTime(dateFormat.format(new Date())); } if("thisQuarter".equals(timeFlage)){ SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); this.setProjectBeginTime(dateFormat.format(DateUtils.getCurrentQuarterStartTime())); this.setProjectEndTime(dateFormat.format(new Date())); } if("thisYear".equals(timeFlage)){ SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); this.setProjectBeginTime(dateFormat.format(DateUtils.getCurrentYearStartTime())); this.setProjectEndTime(dateFormat.format(new Date())); } this.timeFlage = timeFlage; }之后进入控制层之后,实体类对应的开始结束时间,就会有对应的值.