LayUI日历控件使用--如何向后台传值

上代码

1.html代码


				

2.js代码

//时间控件
	layui.use('laydate', function(){
		var laydate = layui.laydate;
		laydate.render({
		    elem: '#rangeTime'
			,type: 'datetime'
			,range: true
			,done: function(value, date, endDate){
				StartTime = data_string_layui(date);
				EndTime = data_string_layui(endDate);
			  }
			
		  });
		})

 /**
  * 日期转换--只针对layui
  * @param dateObj
  * @returns
  */
 function dateToStringForLayui(dateObj) {
		var FullYear = dateObj.year;
		var Month = dateObj.month;
		var Day = dateObj.date;
		var Hours = dateObj.hours;
		var Minutes = dateObj.minutes;
		var Seconds = dateObj.seconds;
	return FullYear+"-"+Month+"-"+Day+" "+Hours+":"+Minutes+":"+Seconds

}

3.后台java代码

@RequestMapping("searchWhiteList")
	public ModelAndView searchWhiteList(Integer curr,Integer limit, String expirationDateBeginStr, String expirationDateEndStr){
		
		if(StringUtil.isNotEmpty(expirationDateBeginStr)) {
			vehicleWhitelist.setExpirationDateBegin(DateTimeUtil.parse(expirationDateBeginStr, FORMAT_TYPE.DATE_TIME));
		}
		if(StringUtil.isNotEmpty(expirationDateEndStr)) {
		vehicleWhitelist.setExpirationDateEnd(DateTimeUtil.parse(expirationDateEndStr, FORMAT_TYPE.DATE_TIME));	
		}
		ModelAndView mv = new ModelAndView();
		mv.setView(Jackson2Util.jsonView());
		page=curr==null?1:curr;
		rows=limit==null?10:limit;
		// 使用PageHelper分页
		PageHelper.startPage(page, rows);
		List vehicleWhiteList = null;		
		Page page = (Page)vehicleWhiteList;
		long total=page.getTotal();
		mv.addObject("count",total );
		mv.addObject("code", 0);
		mv.addObject("data", vehicleWhiteList);
		return mv;
	}

注意:layui从前端页面向后端Controller穿参数 都是String 类型格式 ,后台需要转换相应的类型使用

你可能感兴趣的:(layui)