在我的Grails应用程序中,我需要将请求参数绑定到Date命令对象的字段.为了执行所述字符串到日期转换,需要注册的适当属性编辑在grails-app\conf\spring\resources.groovy
我添加了以下bean定义:
import org.springframework.beans.propertyeditors.CustomDateEditor
import java.text.SimpleDateFormat
beans = {
paramDateEditor(CustomDateEditor, new SimpleDateFormat("dd/MM/yy"), true) {}
}
Run Code Online (Sandbox Code Playgroud)
但我仍然收到一个错误:
java.lang.IllegalArgumentException: Could not parse date: Unparseable date: "04/01/99"]
Run Code Online (Sandbox Code Playgroud)
我认为我定义bean的方式可能有些不对劲,但我不知道是什么?