【发布时间】:2017-11-12 05:09:52
【问题描述】:
我正在尝试在 Grails 命令对象/表单中的地图中添加另一层嵌套。命令对象当前有一个名为 otherData 的 Map。
Map otherData
表单的字段具有如下所示的命名约定,提交时会生成地图。
<input id="birthDate" name="otheData[birthDate]" type="hidden" value="">
<input id="county" name="otheData[county]" type="hidden" value="">
然后在表单提交时在我的控制器中,如果有任何数据要执行搜索,我会将其绑定到另一个地图。
if(otherData) {
_searchCriteria.otherData = otherData
}
我基本上想要另一层不确定性,这样我就可以检查另一个关键路径并对数据执行正确的操作。示例如下:
if(searchCriteria otherData.relativeDate) {
....
} else if(searchCriteria otherData.absoluteDate) {
....
}
我已尝试对输入的名称进行编码以表示嵌套映射,但它没有在我的控制器中创建嵌套映射。
<input id="birthDate" name="otheData[relative:[birthDate]]" type="hidden" value="">
它正在生成一个带有 keypath 的地图
otherData.relative:[birthDate
有没有办法在结构中添加另一层?
【问题讨论】: