JAVA异常:java.lang.ClassCastException:[Ljava.lang.Object; cannot be cast to com.entity.Advertisempublic String find_ad() throws Exception {//action中的System.out.println("进入find_add");this.setCurrentPage(1);//设当前页为1this.setPageSiz
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/05 12:49:39
![JAVA异常:java.lang.ClassCastException:[Ljava.lang.Object; cannot be cast to com.entity.Advertisempublic String find_ad() throws Exception {//action中的System.out.println(](/uploads/image/z/4705608-48-8.jpg?t=JAVA%E5%BC%82%E5%B8%B8%EF%BC%9Ajava.lang.ClassCastException%3A%5BLjava.lang.Object%3B+cannot+be+cast+to+com.entity.Advertisempublic+String+find_ad%28%29+throws+Exception+%7B%2F%2Faction%E4%B8%AD%E7%9A%84System.out.println%28%22%E8%BF%9B%E5%85%A5find_add%22%29%3Bthis.setCurrentPage%281%29%3B%2F%2F%E8%AE%BE%E5%BD%93%E5%89%8D%E9%A1%B5%E4%B8%BA1this.setPageSiz)
JAVA异常:java.lang.ClassCastException:[Ljava.lang.Object; cannot be cast to com.entity.Advertisempublic String find_ad() throws Exception {//action中的System.out.println("进入find_add");this.setCurrentPage(1);//设当前页为1this.setPageSiz
JAVA异常:java.lang.ClassCastException:[Ljava.lang.Object; cannot be cast to com.entity.Advertisem
public String find_ad() throws Exception {//action中的
System.out.println("进入find_add");
this.setCurrentPage(1);//设当前页为1
this.setPageSize(5);//设置每页显示条数,这两个当作参数传进去查出list
List list=advertisementDao.PageList(this.getCurrentPage(),this.getPageSize());
System.out.println(list.size());
/////////////////////下面的for是测试用来在后台输出的advertisement对象getAdName
for(int i=0;i
JAVA异常:java.lang.ClassCastException:[Ljava.lang.Object; cannot be cast to com.entity.Advertisempublic String find_ad() throws Exception {//action中的System.out.println("进入find_add");this.setCurrentPage(1);//设当前页为1this.setPageSiz
类型转换错误..
比如你有个A类和B类..两个类没有任何关系..
然后你A a = new A();
B b = (B)a;
这样就运行期就会报这个异常了..
但是假如你的B类继承自A类就不会了..
如果你想避免这个错误的话..
可以在转型前检查一下..a对象是否是B类型..用instanceof关键字..
比如if(a instanceof B) 这样就行了..
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela