专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Java Web开发

求解:java.lang.IndexOutOfBoundsException: Index: 一, Size: 1

发布时间:2010-05-31 07:00:45 文章来源:www.iduyao.cn 采编人员:星星草
求解:java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
我用Hibernate查询:
hql = "select u.email, u.password from ApplicantPO as u where u.username=?";
  query = sessionH.createQuery(hql);
  query.setString(0, Username);

  list.clear();
  list = query.list();
  System.out.println("list.size() = " + list.size());

  if(list.size()>0){
  this.setEmail(list.get(0).toString().trim()); //给email赋值
  System.out.println("查到的email为:"+list.get(0).toString().trim());
  this.setUserPassword(list.get(1).toString().trim()); //给userPassword赋值
  }
  HibernateServiceProvider.closeSession();

得到的是这样的结果:
list.size() = 1
查到的email为:[Ljava.lang.Object;@13cebda
2011-7-26 21:32:36 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet default threw exception
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at rims.action.GetPasswordAction.checkUser(GetPasswordAction.java:133)
at rims.action.GetPasswordAction.validate(GetPasswordAction.java:153)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:200)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)

麻烦大家指点一二~

------解决方案--------------------
list.get(0).toString().trim()
------解决方案--------------------
数组越界
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: