Grails绑定日期 [英] Grails date binding

查看:134
本文介绍了Grails绑定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Book b = new Book()
bindData (b,params)

如果我有一个特定格式的日期字段(如yyyy-MM- dd)从用户输入?在Spring中,我们可以使用registerCustomEditor()。 Grails是如何实现的?

解决方案

使用Grails 1.1.1,可以实现一个PropertyEditorRegistrar,并使用它来指定格式。请参阅 http ://grails.1312388.n4.nabble.com/Grails-1-1-1-change-in-binding-date-properties-td1323105.html


In Grails, one can 'bindData' in controller:

Book b = new Book()
bindData(b, params)

What if I have a date field with specific format (e.g. yyyy-MM-dd) from user input? In Spring, we can use registerCustomEditor(). How about Grails?

解决方案

With Grails 1.1.1, you can implement a PropertyEditorRegistrar and use that to specify a format. See http://grails.1312388.n4.nabble.com/Grails-1-1-1-change-in-binding-date-properties-td1323105.html

这篇关于Grails绑定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆