Manually Set Map Value in Struts 2
来源:互联网 发布:linux vim 删除一行 编辑:程序博客网 时间:2024/06/16 22:31
you have to duplicate the format that Struts uses to receive the data. For example, to send a list of items (such as List<String> names;
), you would format your URL to look like
&names=johnny&names=tim&names=bill
Maps are a little harder. To create a URL to send to a map, you can use the following format:
&variableName[key]=value
Say you have the following map:
Map<Integer, Integer> userIdOrderIdMap = new HashMap<Integer, Integer>();
To set the map from Struts 2, you’d use the following URL string:
&userIdOrderIdMap[0]=1&userIdOrderIdMap[10]=15
This is the equivalent of:
userIdOrderIdMap.put(0, 1);
userIdOrderIdMap.put(10, 15);
You will probably have to manually call encodeURIComponent() on the URL string to make sure the brackets and any other special characters are escaped properly, but you already knew that, right?
You can also use a dot notation (such as &variableName.key=value
), but I find that a bit counterintuitive to the way KVC types are intended to be represented.
- Manually Set Map Value in Struts 2
- struts 标签遍历map,value为List
- Convert Value type to Map in Golang
- List, Set, Vector and Map in Java
- How to set value of Q0000-MASSN in FM HR_INFOTYPE_OPERATION
- How to set a hidden value in Razor
- How to correctly set application badge value in iOS 8?
- how to set value for cmake arguement in command
- Column ‘nature’ has duplicated value ‘婆婆妈妈’ in SET
- Change Column Name or Set Default Value in MySql
- what happened when we don't set the namespace attrribute in Struts 2?
- hadoop问题Type mismatch in value from map解决方法
- hadoop问题Type mismatch in value from map解决方法
- hadoop-1.0.4 Type mismatch in value from map解决方法
- Struts 2 in Action
- Something about set list and map in Java
- Difference between Set, List and Map in Java - Interview question
- Be cautious when using Map and Set in Java
- Open Tools for Machine Learning
- mysql快速分页-索引性能分析-索引-order by-limit-offset-covering-index
- J2EE综合:如何处理大数据量的查询
- 当SCP遇到循环软连接时
- 2009的祭诞
- Manually Set Map Value in Struts 2
- 汇编心得
- Machine Learning Softwares
- [转载]程序员笑话
- 在Fedora 12上安装RealPlayer 11
- C# WinForm ComboBox控件美化换肤
- [转载]有关虚函数
- 有趣的回车符
- 传智播客-jpa与hibernate(2)-CRUD和关联关系