【发布时间】:2013-06-21 06:31:33
【问题描述】:
我有一个 ParameterMap 集,不同场景下的参数完全不同
我需要的是 ParameterMap 中的“键”字符串数组
我得到的最接近的是使用 reportParams.toString(); 这是我用来获得以下输出的内容
ParameterMap reportParams = context.getRequestParameters();
System.out.println(reportParams.toString());
// 输出
map['username' -> 'user', 'decorate' -> 'no', 'decorator' -> 'empty', 'ajax' -> 'true', '_eventId' -> 'refreshReport', 'VEFactorSelection'-> '1', 'campusAndFaculty' -> 数组['111', '113', '115', '118', '112', '114', '116', '117', '21907 ', '21908', '99040', '99010', '99100', '99230', '99240'], '_flowExecutionKey' -> 'e4s1', 'reportLanguage' -> '3', '日期' -> '2013/06/20', 'nameType2' -> '1', '确认' -> 'true']
所以我想要的最终结果是
用户名、装饰、装饰器、ajax、_ecentId、VEFactorSelection、campusAndFaculty、_flowExecutionKey、reportLanguage、日期、nameType2、确认
我试过了
ParameterMap reportParams = context.getRequestParameters();
final List<String> names = new ArrayList<String>();
for (final Object o: reportParams.asMap().keySet())
names.add((String) o);
final String[] array = names.toArray(new String[names.size()]);
System.out.println(array[0]); // this part is just to see if i get output
以上代码的最终结果:
==================================== org.springframework.beans.ConversionNotSupportedException:转换属性失败属性“readOnlyConfiguredExporters”的“java.util.LinkedHashMap”类型的值到所需的“org.hibernate.mapping.Map”类型;嵌套异常是 java.lang.IllegalStateException:无法将类型 [java.util.LinkedHashMap] 的值转换为属性“readOnlyConfiguredExporters”所需的类型 [org.hibernate.mapping.Map]:找不到匹配的编辑器或转换策略
================================ 一些额外的
这里是“ParameterMap”的APIhttp://static.springsource.org/spring-webflow/docs/1.0.x/api/org/springframework/webflow/core/collection/ParameterMap.html
【问题讨论】:
-
从您链接的 API 文档中,
ParamterMap似乎没有asMap()方法。它是MapAdaptable接口的一部分,由LocalParameterMap和MockParameterMap实现。但是代码甚至不应该编译。