这个问题把小编急毁了,捣腾了好几天还没有结果出来,今天终于捣腾出来了,下面小编把经过分享给大家,大家多多提出宝贵意见。
错误信息如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
@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 集合
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<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类型,就以为还要加引号以表示传入的是字符串,其实是错的,还是初学对其还不太了解。
如下:
错误的:
1
2
3
|
<update id= "updatestate" parametertype= "java.lang.string" >
update login set state = 0 where lid = '#{value}'
</update>
|
正确的:
1
2
3
|
<update id= "updatestate" parametertype= "java.lang.string" >
update login set state = 0 where lid = #{value}
</update>
|
以上所述是小编给大家介绍的mabatis错误提示parameter index out of range的处理方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:https://www.cnblogs.com/dream-saddle/archive/2018/08/22/9515775.html