91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Mabatis錯誤提示Parameter index out of range的處理方法

發布時間:2020-09-17 07:58:12 來源:腳本之家 閱讀:590 作者:Dream_saddle 欄目:編程語言

這個問題把小編急毀了,搗騰了好幾天還沒有結果出來,今天終于搗騰出來了,下面小編把經過分享給大家,大家多多提出寶貴意見。

錯誤信息如下

08:34:43,302 DEBUG getTeachers:139 - ==> Preparing: SELECT a.*,b.classId,b.className FROM TeacherInfo a INNER JOIN ClassInfo b ON a.teacherId=b.teacherId 
08:34:43,316 DEBUG NewPooledConnection:430 - com.mchange.v2.c3p0.impl.NewPooledConnection@2f187f handling a throwable.
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:862)
 at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3319)
 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3304)
 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3341)
 at com.mysql.jdbc.PreparedStatement.setNull(PreparedStatement.java:3380)
 at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setNull(NewProxyPreparedStatement.java:157)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:70)
 at com.sun.proxy.$Proxy34.setNull(Unknown Source)
 at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:43)
 at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)
 at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)
 at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)
 at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)
 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
 at com.sun.proxy.$Proxy15.selectList(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
 at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
 at com.sun.proxy.$Proxy20.getTeachers(Unknown Source)
 at com.taohan.online.exam.service.impl.TeacherInfoServiceImpl.getTeachers(TeacherInfoServiceImpl.java:59)
 at com.taohan.online.exam.handler.ClassInfoHandler.preUpdateClass(ClassInfoHandler.java:176)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Unknown Source)
08:34:43,319 DEBUG SqlUtils:85 - Attempted to convert SQLException to SQLException. Leaving it alone. [SQLState: S1009; errorCode: 0]
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:862)
 at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3319)
 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3304)
 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3341)
 at com.mysql.jdbc.PreparedStatement.setNull(PreparedStatement.java:3380)
 at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setNull(NewProxyPreparedStatement.java:157)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:70)
 at com.sun.proxy.$Proxy34.setNull(Unknown Source)
 at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:43)
 at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)
 at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)
 at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)
 at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)
 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
 at com.sun.proxy.$Proxy15.selectList(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
 at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
 at com.sun.proxy.$Proxy20.getTeachers(Unknown Source)
 at com.taohan.online.exam.service.impl.TeacherInfoServiceImpl.getTeachers(TeacherInfoServiceImpl.java:59)
 at com.taohan.online.exam.handler.ClassInfoHandler.preUpdateClass(ClassInfoHandler.java:176)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Unknown Source)
08:34:43,320 DEBUG DefaultConnectionTester:126 - Testing a Connection in response to an Exception:
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:862)
 at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3319)
 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3304)
 at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3341)
 at com.mysql.jdbc.PreparedStatement.setNull(PreparedStatement.java:3380)
 at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setNull(NewProxyPreparedStatement.java:157)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:70)
 at com.sun.proxy.$Proxy34.setNull(Unknown Source)
 at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:43)
 at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:81)
 at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:80)
 at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:61)
 at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:74)
 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
 at com.sun.proxy.$Proxy15.selectList(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:231)
 at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
 at com.sun.proxy.$Proxy20.getTeachers(Unknown Source)
 at com.taohan.online.exam.service.impl.TeacherInfoServiceImpl.getTeachers(TeacherInfoServiceImpl.java:59)
 at com.taohan.online.exam.handler.ClassInfoHandler.preUpdateClass(ClassInfoHandler.java:176)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222)
 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814)
 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)
 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Unknown Source)

錯誤信息關鍵描述

Parameter index out of range (1 > number of parameters, which is 0)

  反正就是說我的參數存在問題

業務代碼描述

  修改班級信息時可以修改班級對應班主任,所以需要查詢出對應的非班主任教師。

  Handler

@RequestMapping(value="edit/class/{classId}", method=RequestMethod.GET)
 public ModelAndView preUpdateClass(@PathVariable("classId") Integer classId) {
  logger.info("預修改班級處理");
  ModelAndView model = new ModelAndView();
  //獲取要修改班級
  ClassInfo classInfo = classInfoService.getClassById(classId);
  model.setViewName("/admin/classedit");
  model.addObject("editClass", classInfo);
  List<GradeInfo> grades = gradeInfoService.getGrades();
  //獲取不是班主任的教師
  teacher.setIsWork(0); // isWork為0就不是班主任
  List<TeacherInfo> teachers = teacherInfoService.getTeachers(null); //通過下面配置文件可知,該方法需要傳入一個 Map 集合,而我這里傳入一個 null
  //如果沒有可用班主任
  if (teachers.size() == 0 || teachers == null) {
   teacher.setTeacherId(classInfo.getTeacher().getTeacherId());
   teacher.setTeacherName("暫無剩余教師");
   teachers.add(teacher);
  }
  model.addObject("teachers", teachers);
  model.addObject("grades", grades);
  return model;
 }

  映射文件

    Statement會接收一個 Map 集合

<resultMap type="com.taohan.online.exam.po.TeacherInfo" id="getTeacherResultMap">
  <id column="teacherId" property="teacherId"/>
  <result column="teacherName" property="teacherName" />
  <result column="teacherAccount" property="teacherAccount"/>
  <result column="teacherPwd" property="teacherPwd"/>
  <result column="adminPower" property="adminPower"/>
  <result column="isWork" property="isWork"/>
  <association property="classInfo" javaType="com.taohan.online.exam.po.ClassInfo">
   <id column="classId" property="classId"/>
   <result column="className" property="className"/>
  </association>
 </resultMap>
 <parameterMap type="java.util.Map" id="getTeachersParameterMap">
  <!-- 教師對象 -->
  <parameter property="teacher" resultMap="getTeacherResultMap"/>
  <!-- 起始位置索引 -->
  <parameter property="startIndex" resultMap="getTeacherResultMap"/>
  <!-- 每頁顯示數據量 -->
  <parameter property="pageShow" resultMap="getTeacherResultMap"/>
 </parameterMap>
 <!-- 使用 paramenterMap 查詢 -->
 <select id="getTeachers" parameterMap="getTeachersParameterMap" resultMap="getTeacherResultMap">
  SELECT a.*,b.classId,b.className FROM TeacherInfo a
  INNER JOIN ClassInfo b ON a.teacherId=b.teacherId
     <!-- 
      getTeachers()方法我傳入的是 null,那么,在下面進行條件判斷的時候并不能找到 teacher、startIndex、pageShow,所以拋出異常
      -->
  <where>
   <if test="teacher != null">
    isWork=#{teacher.isWork}
   </if>
  </where>
  <if test="startIndex != null and pageShow != null">
   LIMIT #{startIndex}, #{pageShow}
  </if>
 </select>

總結

  通過之前犯過類似的錯誤,以及這次錯誤,我發現 今后只要是 Parameter index out of range (1 > number of parameters, which is 0) 類似的錯誤大致定位在 映射文件和調用方法傳入參數,

  映射文件

    如果使用了 parameterMap, resultMap,或是返回集合,就要檢查參數名稱和屬性名稱是否一致

  調用方法

    針對使用了 parameterMap 或 parameterType,需要檢查傳入Map中的鍵是否存在、匹配,或傳入對象是否存在指定屬性

下面看下在數據庫中遇到Parameter index out of range  錯誤該如何處理?

最近學ssm框架的時候,遇到了這個錯誤,找了半天的原因,最后發現原來是sql語句中多了一對單引號。傳入值的類型為String類型,就以為還要加引號以表示傳入的是字符串,其實是錯的,還是初學對其還不太了解。

如下:

錯誤的:

<update id="updateState" parameterType="java.lang.String">
   UPDATE login SET State = 0 WHERE LID = '#{value}'
</update>

正確的:

<update id="updateState" parameterType="java.lang.String">
   UPDATE login SET State = 0 WHERE LID = #{value}
</update>

以上所述是小編給大家介紹的Mabatis錯誤提示Parameter index out of range的處理方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對億速云網站的支持!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

宜都市| 洛宁县| 大庆市| 轮台县| 方山县| 普陀区| 阿尔山市| 衡南县| 常熟市| 栾城县| 楚雄市| 微山县| 同德县| 安图县| 古丈县| 平安县| 闻喜县| 金堂县| 佛教| 海宁市| 滕州市| 左贡县| 芒康县| 同心县| 保德县| 滦南县| 大厂| 前郭尔| 桂平市| 汕尾市| 吉水县| 广东省| 罗山县| 张家口市| 桃园市| 石泉县| 无为县| 德清县| 兴海县| 莱芜市| 普定县|