java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
javax.servlet.ServletException: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
com.city.bar.action.MenuAddAction.execute(MenuAddAction.java:68)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
出现这种错误可能的原因是什么?
MenuAddAction.java的68行,出现型类的转换错误正仿。
你在档桐试举蠢纤图把某个Object转换成String时出现错误。
型局贺类扮腊渣不匹配
一般在类型转换时
例如厅悄: (Date)(new Long(1)) 就会出这个类型的错误
List<绝凳?> offlist=Sys_Pagination.getAaData();
List<Map> list=new ArrayList<Map>();
for(int i=0;i<offlist.size();i++){
Object[] obj = (Object[])offlist.get(i);
Map<明世String,Object> map=new HashMap<String,Object>();
map.put("maintype", obj[0]);
map.put("sectype", obj[1]);
map.put("suppliesname", obj[2]);
map.put("unit", obj[3]);
map.put("inventory"并槐旅, obj[4]);
map.put("sunQuant", obj[5]);
map.put("sunOutQuant", obj[6]);
map.put("appQuant", obj[7]);
list.add(map);
}
Sys_Pagination.setAaData(list);
应该是JSP页面有多个相同元素~