程序出现java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!错误javax.servlet.ServletException:java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!org.apache.struts2.dispatcher.Dispatche

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 17:13:23
程序出现java.lang.IndexOutOfBoundsException:Rememberthatordinalparametersare1-based!错误javax.servlet.Serv

程序出现java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!错误javax.servlet.ServletException:java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!org.apache.struts2.dispatcher.Dispatche
程序出现java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!错误
javax.servlet.ServletException:java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!
org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterDescriptor(ParameterMetadata.java:55)
org.hibernate.engine.query.ParameterMetadata.getOrdinalParameterExpectedType(ParameterMetadata.java:61)
org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:397)
org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:369)
com.my.dao.impl.UserInfoDAOImpl.search(UserInfoDAOImpl.java:119)
com.my.control.UserInfoControl.searchUserInfo(UserInfoControl.java:143)
代码如下
//根据用户姓名查询用户信息
public UserInfo search(String realName,String workNo) {
Session session=HibernateSessionFactory.getSession();
String hql=" from UserInfo as user where 1=1";
Query query=session.createQuery(hql);
if(realName.equals("")){
hql=hql+" and user.workNo like ";
query.setParameter(0,workNo);
}
if(workNo.equals("")){
hql=hql+" and user.realName like ";
query.setParameter(0,realName);
}
if(!realName.equals("") && workNo.equals("")){
hql=hql+" and user.realName like and user.workNo like ";
119行//query.setParameter(0,realName);
query.setParameter(1,workNo);
}

程序出现java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!错误javax.servlet.ServletException:java.lang.IndexOutOfBoundsException:Remember that ordinal parameters are 1-based!org.apache.struts2.dispatcher.Dispatche
Remember that ordinal parameters are 1-based!
提示信息已经告诉你了,是从1开始,不是0开始.