一、controller
/**
* 检查预订开始时间和结束时间的合法性
* @param startTime
* @param endTime
* @return
*/
@RequestMapping(value = "checkTime")
@ResponseBody
public String checkTime(String startTime, String endTime) {
int space=TimeUtils.getTimeSpac(startTime+":00",endTime+":00",TimeUtils.BENCHMARK);
HashMap map=new HashMap();
if(space>=2 && space%2==0){
map.put("rs","1");
map.put("msg","检测成功");
}else if(space<=0){
map.put("rs","0");
map.put("msg","开始时间应该小于结束时间");
}else if(space%2!=0){
map.put("rs","0");
map.put("msg","最小时间单位为一个小时");
}
return JSON.toJSONString(map);
}
二、Jquery