问答详情
源自:3-7 request对象(上)

用for循环就报错

四月 20, 2015 9:49:18 上午 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet [jsp] in context with path [/test1] threw exception [An exception occurred processing JSP page /requstTest.jsp at line 33


30:    <% 

31:      String[] Aihao= request.getParameterValues("aihao");

32:      for(int i=0;i<=Aihao.length;i++){

33:      if(Aihao[i]==null){

34:      out.println("浣犱斧鐨勬病杈撳叆鐖卞ソ銆傘?傛垜浠?庝箞鐜╋紵");

35:      }

36:      out.println(Aihao[i]);}



Stacktrace:] with root cause


提问者:修挖机的猿 2015-04-20 09:55

个回答

  • 好帮手慕珊
    2015-04-20 13:55:45

    for循环中i<=Aihao.length;改为i<Aihao.length,数组的下标最大也就是数组长度-1