java.lang.IndexOutOfBoundsException着急

List studentReadings = new ArrayList();

    List<UUser> user = userService.queryUserNameByClassId(classId);
    for (int i = 0;i < user.size(); i++){
        studentReadings.get(i).setUserStudentId(user.get(i).getUserStudentId());
        studentReadings.get(i).setUserName(user.get(i).getUserName());
        Integer count = readingLogService.queryReadingCount(user.get(i).getUserId());
        studentReadings.get(i).setReadingCount(count);
        float score = homeworkService.selectInitialScore(user.get(i).getUserId());
        studentReadings.get(i).setCountScore(score);
        studentReadings.get(i).setReadingScore(score);
        List<String> resourceIdList = homeworkService.selectResourceId(user.get(0).getUserId());
        studentReadings.get(i).setReadingCount(resourceIdList.size());
        int readingwordCount = 0;
        for(int j = 0; j < resourceIdList.size(); j ++){
            TArticleInfo articleInfo = articleInfoService.selectWordcount(resourceIdList.get(i));
            readingwordCount =+ articleInfo.getWordcount();
        }
        studentReadings.get(i).setReadingSize(readingwordCount);
    }

你要把Log贴出来啊。

studentReadings.get(i) 下标是否越界,因为你的循环范围是根据 user的大小设置的。

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_65]
at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_65]
at com.langying.resources.HomeworkTeacherAction.getStudentReadingStatisticsByClass(HomeworkTeacherAction.java:718) ~[main/:na]
at com.langying.resources.HomeworkTeacherAction$$FastClassBySpringCGLIB$$301db295.invoke() ~[main/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:718) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at com.langying.aspect.LogAspect.doAround(LogAspect.java:112) ~[main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]

越界异常,看看list是否越界

for(int j = 0; j < resourceIdList.size(); j ++){
TArticleInfo articleInfo = articleInfoService.selectWordcount(resourceIdList.get(i));
readingwordCount =+ articleInfo.getWordcount();
}
这一段resourceIdList.get(i)是不是应该是get(j);