我需要解码(URLDecode.decode)命名列表中的每个对象。我尝试通过命名列表进行迭代
for (NamedList nlst : allLists) {
try {
Namedlist temp =(NamedList) UrlDecode.decode(nlst.toString(),"UTF-8");
}
但它不允许我投进一个命名列表。
请让我知道如何实现这一点。
我需要解码(URLDecode.decode)命名列表中的每个对象。我尝试通过命名列表进行迭代
for (NamedList nlst : allLists) {
try {
Namedlist temp =(NamedList) UrlDecode.decode(nlst.toString(),"UTF-8");
}
但它不允许我投进一个命名列表。
请让我知道如何实现这一点。
You cannot cast a String to custom defined class. Think about this way what you are going to do if you want to cast an Integer instance to a String, you will probably use static factory method valueOf() to convert Integer to a String rather than casting it.
So a workaround here is to provide your own static factory method in something like XXXUtil.java
public static NamedList valueOf(String s){
//TODO convert string to namedlist
}