1 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'couId' not found. Available parameters are [1, 0, param1, param2] 2 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) 3 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364) 4 at com.sun.proxy.$Proxy15.selectList(Unknown Source) 5 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194) 6 at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114) 7 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58) 8 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) 9 at com.sun.proxy.$Proxy17.getSCBycouAndcla(Unknown Source) 10 at cn.springmvc.serviceiml.SortCourseServiceIml.addSCs(Unknown Source) 11 at cn.springmvc.controller.SortCourseController.leadinSCs(Unknown Source) 12 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 13 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 14 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 15 at java.lang.reflect.Method.invoke(Method.java:606) 16 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 17 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) 18 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) 19 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) 20 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) 21 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) 22 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838) 23 at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) 24 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) 25 at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) 26 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 27 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 28 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 29 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 30 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 31 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 32 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 33 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 34 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 35 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) 36 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 37 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 38 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) 39 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 40 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) 41 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 42 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) 43 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083) 44 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640) 45 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 46 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 47 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 48 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 49 at java.lang.Thread.run(Thread.java:744) 50 Caused by: org.apache.ibatis.binding.BindingException: Parameter 'couId' not found. Available parameters are [1, 0, param1, param2] 51 at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:160) 52 at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:41) 53 at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:113) 54 at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:72) 55 at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:77) 56 at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58) 57 at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:71) 58 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56) 59 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) 60 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) 61 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) 62 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) 63 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) 64 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) 65 at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source) 66 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 67 at java.lang.reflect.Method.invoke(Method.java:606) 68 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354) 69 ... 46 more 70 十月 15, 2017 11:35:33 上午 org.apache.catalina.core.StandardWrapperValve invoke 71 严重: Servlet.service() for servlet [spring] in context with path [/studentleader] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'couId' not found. Available parameters are [1, 0, param1, param2]] with root cause 72 org.apache.ibatis.binding.BindingException: Parameter 'couId' not found. Available parameters are [1, 0, param1, param2] 73 at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:160) 74 at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:41) 75 at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:113) 76 at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:72) 77 at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:77) 78 at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58) 79 at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:71) 80 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56) 81 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) 82 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) 83 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) 84 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) 85 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) 86 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) 87 at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source) 88 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 89 at java.lang.reflect.Method.invoke(Method.java:606) 90 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354) 91 at com.sun.proxy.$Proxy15.selectList(Unknown Source) 92 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194) 93 at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114) 94 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58) 95 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43) 96 at com.sun.proxy.$Proxy17.getSCBycouAndcla(Unknown Source) 97 at cn.springmvc.serviceiml.SortCourseServiceIml.addSCs(Unknown Source) 98 at cn.springmvc.controller.SortCourseController.leadinSCs(Unknown Source) 99 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 100 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 101 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 102 at java.lang.reflect.Method.invoke(Method.java:606) 103 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 104 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) 105 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) 106 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) 107 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) 108 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) 109 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838) 110 at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) 111 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) 112 at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) 113 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 114 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 115 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 116 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 117 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 118 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 119 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 120 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 121 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 122 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) 123 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 124 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 125 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) 126 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 127 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) 128 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 129 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) 130 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083) 131 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640) 132 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) 133 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 134 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 135 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 136 at java.lang.Thread.run(Thread.java:744)
今天写项目,写到多个参数从数据库取数据时,一直报这个错,经过查找资料等,终于成功解决,解决前代码为
DAO层
修改前:
public ListgetSC(String couId,String classname);
mapper.xml
修改前:
因为mapper配置文件中parameterType为String,只能接收一个参数,故将parameterType属性去掉
则修改第一步:将mapper.xml中将parameterType属性去掉
修改后:
修改第二步:将DAO成代码修改为
修改后:
public ListgetSC(@Param("couId")String couId,@Param("classname")String classname);
再导入Param包
问题成功解决!!