我正在尝试使用Wicket中的键String和值来添加和获取.List<object>PageParameters
虽然我用钥匙取得价值,但我得到了 classcastException:String cant be converted into list.
我使用的是这样的东西:
List<Example> list = (List<Example>)params.get("ExampleList");
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
您无法存储对象,PageParameters因为它PageParameters是HTTP请求参数的抽象,协议仅支持String值.您必须从参数中获取字符串列表并将其处理为Example对象.
List<StringValue> values = parameters.getValues("examples");
for(StringValue value : values) {
Example example = new Example(value.toString());
examples.add(example);
}
Run Code Online (Sandbox Code Playgroud)