在我的Grails应用程序中,我需要将请求参数绑定到命令对象的
我已添加以下bean定义:
但是我仍然在遇到错误:
Date
字段。为了执行从字符串到日期的转换,需要在grails-app\conf\spring\resources.groovy
注册适当的PropertyEditor属性编辑器。我已添加以下bean定义:
import org.springframework.beans.propertyeditors.CustomDateEditor
import java.text.SimpleDateFormat
beans = {
paramDateEditor(CustomDateEditor, new SimpleDateFormat("dd/MM/yy"), true) {}
}
但是我仍然在遇到错误:
java.lang.IllegalArgumentException: Could not parse date: Unparseable date: "04/01/99"]
我认为可能是我定义Bean的方法有问题,但我不知道具体是什么问题。
CustomDateEditor.class
作为paramDateEditor()
的第一个参数怎么样?我只是在试探,看看这是否可行。我熟悉Grails,但对于绑定Command对象没有太多经验。 - Rob Hruska