---
title: "spring mvc从页面得到util.Date类型的数据"
author: "xiajava2011"
date: "2011-11-04T15:04:45Z"
tags: []
categories: ["开源软件"]
slug: "spring-mvc-util-date"
draft: false
lastmod: "2011-11-04T15:04:45Z"
id: 1235409
url: "https://xiajava2011.iteye.com/blog/1235409"
---

在控制类中加上

@InitBinder  
    public void initBinder(WebDataBinder binder) {  
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");  
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));  
    }