html - Grails 表格,嵌套 map

标签 html grails

我正在尝试向 Grails 命令对象/表单中的 map 添加另一层嵌套。命令对象当前有一个名为 otherData 的 Map。

Map otherData

表单的字段具有如下所示的命名约定,提交时会生成 map 。
<input id="birthDate" name="otheData[birthDate]" type="hidden" value="">
<input id="county" name="otheData[county]" type="hidden" value="">

然后在表单提交时在我的 Controller 中,如果有任何数据要执行搜索,我会将其绑定(bind)到另一个 map 。
if(otherData) {
    _searchCriteria.otherData = otherData
}

我基本上想要另一层不确定性,这样我就可以检查另一个关键路径并对数据执行正确的操作。下面的例子:
if(searchCriteria otherData.relativeDate) {
    ....
} else if(searchCriteria otherData.absoluteDate) {
    ....
}

我试图对输入的名称进行编码以表示嵌套映射,但它没有在我的 Controller 中创建嵌套映射。
<input id="birthDate" name="otheData[relative:[birthDate]]" type="hidden" value="">

它正在生成带有 keypath 的 map
otherData.relative:[birthDate

有没有办法在结构中添加另一层?

最佳答案

试试 "otheData.relative.birthDate"而不是 otheData[relative:[birthDate]]

关于html - Grails 表格,嵌套 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47245668/

相关文章:

html - 在 Windows 和 Mac 上自动播放 CD 上的 HTML

html - 挂锁的 Unicode 字形

javascript - 同时使用 text() 和 val() 方法与重置按钮表单发生冲突

grails - Grails域 transient 和计算

grails - 完全覆盖或使用前缀覆盖 Grails 脚手架 URL

javascript - 在 javascript 中按类显示隐藏标签(有和没有 JQuery)

javascript - 我的悬停弹出窗口在不应该出现的情况下闪烁和移动

java - Tomcat 6 Web 应用程序随时间消耗内存

javascript - gridcomplete 函数始终运行?

grails - 我在输入类型的文本中输入了一个值,但在params.descrption中使用空值。为什么?