日期:2014-05-20  浏览次数:20797 次

显示list过程中出错,请大家救急,在线等
String   sql   =   "from   tabfunc ";
HibernateDAO   dao   =   new   HibernateDAO();
Session   session   =   dao.getSession();
Query   query   =   session.createQuery(sql);
List   l   =   query.list();

for   (int   i   =   0;   i   <   l.size();   i++)   {
    String[]   str   =   (String[])l.get(i);       //这是100行
    for   (int   j   =   0;   j <str.length;   j++){
        System.out.println(str[j].toString());
    }
}
运行出错了

type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
com.lianchuang.unicrm.pub.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:99)


root   cause  

java.lang.ClassCastException
com.lianchuang.unicrm.grade.report.CityIncomeKeepReportLogic.query(CityIncomeKeepReportLogic.java:100)
com.lianchuang.unicrm.grade.report.CityIncomeKeepReportAction.query(CityIncomeKeepReportAction.java:62)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native   Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
com.lianchuang.unicrm.struts.BaseAction.execute(BaseAction.java:104)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
com.lianchuang.unicrm.pub.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:99)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Tomcat   logs.



------解决方案--------------------
你的list里至少有一个不是String[]类型
------解决方案--------------------
java.lang.ClassCastException;类型不匹配

String[] str = (String[])l.get(i); //这是100行
强制转换出了错
------解决方案--------------------
java.lang.ClassCastException类转型异常
你先把list中每个对象输出来看看啊
System.out.println(l.get(i));
应该有不是String型的
------解决方案--------------------