用于
@ModelAttribute在转到页面之前设置域。
new在处理spring时要谨慎使用,它只会在spring上下文之外创建一个新的对象实例,并且您不能使用任何spring功能(例如Web绑定,验证等)。
例如:
@RequestMapping(value = "/test.htm", method = RequestMethod.GET)public String showForm(@ModelAttribute yourDomain, final ModelMap map)
在您的域中,您可以使用:
@DateTimeFormat(pattern="dd/MM/yyyy")private Date balance = new Date(System.currentTimeMillis());



