Spring MVC的自省机制填充
//User实例package spr.web;import java.util.Date;import java.text.SimpleDateFormat;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.propertyeditors.CustomDateEditor;import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.web.bind.WebDataBinder;import org.springframework.web.bind.annotation.InitBinder;import org.springframework.web.bind.annotation.RequestMapping;import spr.domain.*;import spr.service.*;@Controller@RequestMapping("/user.htm")public class UserController {@Autowiredprivate UserServiceAble userService;//日期类型映射器@InitBinderpublic void initBinder(WebDataBinder binder){SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd");binder.registerCustomEditor(Date.class, new CustomDateEditor(df, false));}@RequestMapping(params="op=doAdd")public String doAdd(User user){System.out.println(user.getName());userService.addUser(user);return "redirect:user.htm?op=list";}}