我们看一下变量seldevices:
Hashtable seldevices = new Hashtable(); ---> 正确
Vector getsel = new Vector();
try
{
seldevices = (Hashtable)session.getAttribute("totsel"); --》如果totsel不存在 , seldevices = null 而不会抛出 NullPointerException
getsel = (Vector)seldevices.get(seltype);
getsel.trimToSize();
}
catch(NullPointerException e)
{}
catch(Exception e)
{}
getsel.add(device);
getsel.trimToSize();
seldevices.put(seltype,getsel); --》seldevices == null !!!!!
这里一定会跳出NullPointerException。
session.setAttribute("totsel",seldevices);
Hashtable seldevices = new Hashtable(); ---> 正确
Vector getsel = new Vector();
try
{
seldevices = (Hashtable)session.getAttribute("totsel"); --》如果totsel不存在 , seldevices = null 而不会抛出 NullPointerException
getsel = (Vector)seldevices.get(seltype);
getsel.trimToSize();
}
catch(NullPointerException e)
{}
catch(Exception e)
{}
getsel.add(device);
getsel.trimToSize();
seldevices.put(seltype,getsel); --》seldevices == null !!!!!
这里一定会跳出NullPointerException。
session.setAttribute("totsel",seldevices);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货