变换类型出错

转换类型出错ArrayListarnewArrayList()ar(ArrayList)session.getAttribute( cart )为什么这样转换

转换类型出错
ArrayList   ar=new   ArrayList();
ar=(ArrayList)session.getAttribute( "cart ");

为什么这样转换要出错

[解决办法]
session.getAttribute( "cart ")返回的不是ArrayList对象
试试打出返回对象的类型看看
System.out.println(session.getAttribute( "cart ").getClass().getName());