velocity - 使用 put on a map in velocity 打印指令
问题描述
我在动态修改的速度模板中有一张地图。下面是一个简化的例子来说明这一点。
#set($testMap = {})
## this stuff isn't static so I can't just create
## the map as key-value pairs in the declaration
$testMap.put("a", "A")
$testMap.put("b", "B")
$testMap
以上生成
$testMap.put("a", "A") $testMap.put("b", "B") {a=A, b=B}
我不希望“放置”指令显示在模板中。
解决方案
我建议您使用条目初始化地图:
#set (testMap = {"a" : "A" , "b" : "B"})
推荐阅读
- python - panda df 迭代,基于时间的数据分箱(以毫秒为单位)
- android - 必须在 val 变量中初始化错误
- bash - 将 && \ 添加到文本文件的每一行,除了最后一行
- delphi - 如何配置 IDE 代码编辑器以将文件保存为“UTF-8 without BOM”?
- java - 带有可选表的 JPA 模型
- adobe - 如何在 AEM Touch UI 对话框中引入具有默认值的附加字段?
- flutter - Flutter 使用过时的包不会让我运行我的应用程序
- jquery - salesforce 使用 jQuery ajax 方法获取令牌
- javascript - 完整日历不是函数 CDN
- r - 计算每个 data.table 行的出现次数