spring封装对象中有时间格式 出现400错误

spring封装对象,如果对象中有时间格式,会出现400错误。

解决方法Controller中第一个方法添加自定义类型转换器

@Controller
@RequestMapping("/log")
public class LogController {
	
	LogService logService = new LogService();
	
	//自定义类型转换器
	@InitBinder
	public void initBinder(HttpServletRequest request,ServletRequestDataBinder binder) throws Exception {
		binder.registerCustomEditor(
				Date.class, 
				new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),true));
	}
	
	@RequestMapping("/getManageLog")
	public ModelAndView getManageLog(ManageLogObj manageLogObj,HttpServletRequest request) throws Exception {
		
		ModelAndView mv = new ModelAndView("/log/manage_log");
		List<ManageLogObj> manageLogObj_list = logService.getManageLog(manageLogObj);
		mv.addObject("manageLogObj_list",manageLogObj_list);
		return mv;
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值