Grails 对象编组 - 添加数据类型提示?
我希望能够拥有这样的东西:
<form>
<input type="date" name="params.date"/>
<input type="text" name="params.myString"/>
</form>
并将其编组到
Map<String, Object> params
['date': (Date object),
'myString': (String)]
命令对象持有者内部,如下所示:
class Holder{
def params
def unshownAttributes
}
我考虑做一些涉及 javascript 的黑客技术来解析 data-type
HTML5 属性并预先准备名称(并稍后修复类型),但我希望有更好的方法可以使用 groovy 或 grails 自动执行此操作。
有什么想法吗?
I'd like to be able to have something like this:
<form>
<input type="date" name="params.date"/>
<input type="text" name="params.myString"/>
</form>
And marshall this to
Map<String, Object> params
['date': (Date object),
'myString': (String)]
inside of a command object holder as such:
class Holder{
def params
def unshownAttributes
}
I thought about doing some hackery involving javascript to parse out a data-type
HTML5 attribute and preprending the name (and fixing up the types later), but I was hoping there was a better way to do this automatically with groovy or grails.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前不存在这样的机制。您可以通过使用适当的命令对象为您需要的每个编组实例创建方法来减轻自己的痛苦。
No such mechanism currently exists. You may save yourself some pain by just creating methods for every marshalling instance you need with proper command objects.