It has been possible to bind a date directly since long before Grails 1.3. The steps are:
(1) Create a class that registers an editor for your date format under grails-app/utils:
import org.springframework.beans.PropertyEditorRegistrar
import org.springframework.beans.PropertyEditorRegistry
import org.springframework.beans.propertyeditors.CustomDateEditor
import java.text.SimpleDateFormat
public class CustomDateEditorRegistrar implements PropertyEditorRegistrar {
public void registerCustomEditors(PropertyEditorRegistry registry) {
String dateFormat = 'yyyy-MM-dd'
registry.registerCustomEditor(Date, new CustomDateEditor(new
SimpleDateFormat(dateFormat), true))
}
}
(2) Make Grails aware of this date editor by registering the following bean in grails-app/conf/spring/resources.groovy
beans = {
customPropertyEditorRegistrar(CustomDateEditorRegistrar)
}
Reference:
http://stackoverflow.com/questions/2871977/binding-a-grails-date-from-params-in-a-controller
http://grails.1312388.n4.nabble.com/Grails-1-1-1-change-in-binding-date-properties-td1323105.html
分享到:
相关推荐
Grails Web 应用框架:grails-core
grails-1.0 中文参考文档 网上收集而来,对 e 文不太熟悉的朋友可以参考一下,有些翻译的不好理解,最好对照着官方的e 文的参考文档
groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.part1 共两个压缩包,解压后将扩展名.zip.bak改为.zip再次解压。
groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.part2 共两个包,解压后需要将扩展名.zip.bak改名为.zip重新解压。 http://dist.springsource.com/release/STS/3.8.1.RELEASE/dist/ e4.6/spring-tool-...
Groovy&Grails - 指南.pptGroovy&Grails - 指南.pptGroovy&Grails - 指南.pptGroovy&Grails - 指南.pptGroovy&Grails - 指南.ppt
elasticsearch-grails-plugin, 恢复的ElasticSearch grails插件 Elasticsearch插件插件这个项目是一个基于Elasticsearch的插件,这个项目是基于的人完成的伟大工作的。你为什么想要为原来的Elasticsearch插件提供...
Grails-2.4.4-用户手册
grails核心源码,版本2.2.2,可以给对grails开发感兴趣的朋友做学习参考。
grails-docs-2.0.0
grails-1.2.2.zip
Grails 4 ships with the following dependency upgrades: Groovy 2.5.6 GORM 7 and Hibernate 5.4 (now the default version of Hibernate for new applications) Spring Framework 5.1.5 Spring Boot 2.1.3 ...
像Rails,Django和TurboGears这样的动态框架在Web开发领域开辟了一条新的道路,Grails基于这些概念之上,采用动态方法减小了Java平台上进行Web开发的复杂度,不过与那些框架不同的是,Grails是构建在Spring和...
prestige.zip,android的mvc模式,android的代码生成驱动的mvc模式。
grails 中文文档+grails-fckeditor-0.9.5.zip插件
漏洞修补好象是传asp等后缀名的时候,生成的是nba的后缀。上传原来很简单在后缀加个空格就可以了
grails-2.3.6
grails-5.1.2.zip
Getting-Started-with-Grails-Chinese,一本不错的grails入门书籍,希望对有志于grails的朋友们有用。
grails-spring-websocket ils子 2.4.x 3.2.7+ 2.5.x 4.0.0+ 安装 要将插件安装到Grails应用程序中,请将以下行添加到build.gradle依赖项部分: implementation "org.grails.plugins:grails-spring-websocket:...
grails-quartz-0.4.1 插件,直接安装