java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.hm.first.action.LoginAction.list(LoginAction.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.hm.util.myfriler.doFilter(myfriler.java:20)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
java.lang.NullPointerException
at com.hm.first.action.LoginAction.list(LoginAction.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.hm.util.myfriler.doFilter(myfriler.java:20)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
大家帮帮忙!谢谢了 !

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【blacksun1002】截止到2008-06-25 17:33:08的历史汇总数据(不包括此帖):
    发帖数:0                  发帖分:0                  
    结贴数:0                  结贴分:0                  
    未结数:0                  未结分:0                  
    结贴率:-------------------结分率:-------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
    at com.hm.first.action.LoginAction.list(LoginAction.java:122) 
      

  3.   

    list.get 时候出的错
    你的list为空吧
      

  4.   

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 看看你传的参数,这样的错误有可能是你传的参数不和要求,
      

  5.   

    明显是你ArrayList里面什么都没有,你却调用他的get(0)方法,所以抛异常
      

  6.   

    这两句代码就能重现你的异常
    List a=new ArrayList();
    System.out.println(a.get(0));使用get()方法是判断一下索引是不是超过List的size就可以避免这种异常了
      

  7.   

    LoginAction.java:122这一行出现了数组越界,应该是list的size为0,你没有查到数据
      

  8.   

    public ActionForward list(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) throws Exception {
    // TODO Auto-generated method stub
    HttpSession session=request.getSession();
    WenzhangAllService service=(WenzhangAllService) SpringBeanFactory.getBean2("WenzhangAllService");
    AdminServer as =(AdminServer) SpringBeanFactory.getBean("adminService");
    ZaixiandiaochaService service2 =(ZaixiandiaochaService) SpringBeanFactory.getBean("ZaixiandiaochaService");
    SecondNameService second=(SecondNameService) SpringBeanFactory.getBean("SecondNameService");
    try{
     PictureService pic=(PictureService) SpringBeanFactory.getBean("PictureService");  Picture p1=pic.get(1);
     Picture p2=pic.get(2);
     Picture p3=pic.get(3);
     Picture p4=pic.get(4);
     Picture p5=pic.get(5);
     Picture p6=pic.get(6);
     Picture p7=pic.get(7);
     Picture p8=pic.get(8);
     Picture p9=pic.get(9);
     Picture p10=pic.get(10);
     Picture p11=pic.get(11);
     Picture p12=pic.get(12);
     Picture p13=pic.get(13);
     Picture p14=pic.get(14);
     Picture p15=pic.get(15);
     Picture p16=pic.get(16);
     request.setAttribute("PICTURE1",p1);
     request.setAttribute("PICTURE2",p2);
     request.setAttribute("PICTURE3",p3);
     request.setAttribute("PICTURE4",p4);
     request.setAttribute("PICTURE5",p5);
     request.setAttribute("PICTURE6",p6);
     request.setAttribute("PICTURE7",p7);
     request.setAttribute("PICTURE8",p8);
     request.setAttribute("PICTURE9",p9);
     request.setAttribute("PICTURE10",p10);
     request.setAttribute("PICTURE11",p11);
     request.setAttribute("PICTURE12",p12);
     request.setAttribute("PICTURE13",p13);
     request.setAttribute("PICTURE14",p14);
     request.setAttribute("PICTURE15",p15);
     request.setAttribute("PICTURE16",p16);
      List listt=as.find("from Admin where username='1'");
    就这里得listt出错了,我不知道他上面这个  listt放得是什么,什么意思,因为代码不是我写得,我刚刚接手!

    Admin adminn=null;
    try{
    if(listt.size()>0)
    adminn=(Admin) listt.get(0);
    }catch(Exception ex){
    ex.printStackTrace();
    }
    Admin login= (Admin) session.getAttribute("HHHHH"); if(login==null){
    if(adminn.getAddress().equals(PublicUtil.getNowDate())){
    adminn.setJifeng(adminn.getJifeng()+1);
    adminn.setZhongfeng(adminn.getZhongfeng()+1);
     }else{
     adminn.setJifeng(1);
     adminn.setZhongfeng(adminn.getZhongfeng()+1);
     adminn.setAddress(PublicUtil.getNowDate());
     }
    as.update(adminn);
    }
    List diaocha_list=service2.getFind(0,15, "from Zaixiandiaocha where hits<3 order by id desc");
    List dongtai_list=service.getFind(0,7, "from WenzhangAll where r1=1002 order by id desc");
    List zhongxin_list =service.getFind(0,15, "from WenzhangAll where r1=1003 order by id desc");
    List xinliAnli_list=service.getFind(0,14, "from WenzhangAll where r1=1004 order by id desc");
    List ganwu_list=service.getFind(0,13, "from WenzhangAll where r1=1005 order by id desc");
    List shequ_list=service.getFind(0,15, "from WenzhangAll where r1=1006 order by id desc"); 
    List quwen_list=service.getFind(0,15, "from WenzhangAll where r1=1007 order by id desc");

    List jitang_list=service.getFind(0,15, "from WenzhangAll where r1=1009 order by id desc");
    List chidian_list=service.getFind(0,15, "from WenzhangAll where r1=1010 order by id desc");
    List zhongheng_list=service.getFind(0,15, "from WenzhangAll where r1=1011 order by id desc");
    List dushixinli_list=service.getFind(0,14, "from WenzhangAll where r1=1012 order by id desc");
    List quanguo_list=service.getFind(0,7, "from WenzhangAll where r1=1013 order by id desc");
    List qianyan_list=service.getFind(0,5, "from WenzhangAll where r1=1014 order by id desc");
    List yichang_list=service.getFind(0,14, "from WenzhangAll where r1=1008 order by id desc");
    List qianyan_list2=service.getFind(6,11, "from WenzhangAll where r1=1014 order by id desc");
    List xuexiao_list=service.getFind(0,36,"from WenzhangAll where r1=1015 order by id desc");
    List yijia_list=service.getFind(0,5, "from WenzhangAll where r1=1016 order by id desc");
    List yijia_list1=service.getFind(6,11, "from WenzhangAll where r1=1016 order by id desc");
    List guanzhu_list=service.getFind(0,7, "from WenzhangAll where r1=1017 order by id desc");
            session.setAttribute("HHHHH",adminn);
    下面代码省略................... }
      

  9.   

    as.find("from Admin where username='1'"); 
    看看as 的 find 方法是不是有错
    或者看看admin这个表有没有数据
      

  10.   

    你没有listt分配内存空间,怎么可能往listt写入value呢.
    应该List listt= new List();
    listt = as.find("from Admin where username='1'"); 
      

  11.   

     “List listt=as.find("from Admin where username='1'");
    就这里得listt出错了,我不知道他上面这个  listt放得是什么,什么意思,因为代码不是我写得,我刚刚接手!
    ”存放符合username为1的所有Admin对象。
    估计是没有符合条件的Admin对象被查询出来,自己检查一下好了
     
      

  12.   

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
    at java.util.ArrayList.RangeCheck(ArrayList.java:547) 
    at java.util.ArrayList.get(ArrayList.java:322) 
    at com.hm.first.action.LoginAction.list(LoginAction.java:122) 
    list.get 时候出的错 list没有值
     
      

  13.   

    IndexOutOfBoundsException 的翻译就是 ...
      

  14.   

    不用说,肯定是list越界了,好好检查下,代码注释都没有,不好看啊。,,,
      

  15.   

    from Admin where username='1'  这句话最终会在数据库执行么?  它会在哪儿找 username='1'的对象?网站是用Struts+spring+hibernate
      

  16.   

    http://topic.csdn.net/u/20070921/08/9a66b266-b44a-47d1-ae4c-4da8168cd67b.html
    看看这个网址,和你出现的问题是否相同啊?
      

  17.   


    try{ 
    if(listt.size()>0) 
    adminn=(Admin) listt.get(0); 
    }catch(Exception ex){ 
    ex.printStackTrace(); 
    } 它已经判断了越界的问题了啊。
    应该不是这里出错的呀
    而且报的错是122行,应该不是这行吧,把下面的也贴出来。
      

  18.   

    at com.hm.first.action.LoginAction.list(LoginAction.java:122) 122行左右的list给出来看看,以及他的声明和初始化
      

  19.   

    list为null吧,这样你在调用get(0)的时候就报错了。
    这样,你加上一个判断if(!list.isEmpty()){list.get(0)},这样就不会报错了。