0
最近我开始在ftl freemarker上工作。 我使用#assign创建了一个hasmap。freemarker,更新hasmap的方法
什么是推荐的方式来更新这个hashMap的值?
数据结构(地图,列表等)在freemarker中是不可变的吗?
<#assign hashMap1= { "name": "mouse", "price": 50 } >
hashMap1.name = "cat"; // gives error
<#assign hashMap1= hashMap1 + {"name": "cat"} /> // this works fine , but I don't like this approach. it gives false sense of adding keys where we are updating keys.
我想经过这里freemarker builtins去,但没有这方面的信息。
添加您在其他答案中给出的参考。 http://freemarker.org/docs/app_faq.html#faq_modify_seq_and_map – k1133