---
title: "SpringMVC日期绑定"
author: "theseus"
date: "2017-10-24T15:48:05Z"
tags: []
categories: ["开源软件"]
slug: "springmvc"
draft: false
lastmod: "2017-10-24T15:48:05Z"
id: 2397456
url: "https://theseus.iteye.com/blog/2397456"
---

在controller中添加以下代码自动绑定日期参数

```
@InitBinder
public void initData(WebDataBinder wdb) {
	wdb.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
}
```