报错信息:Error querying database. Cause: java.lang.NumberFormatException: For input string: “A”

### Error querying database.Cause: java.lang.NumberFormatException: For input string: "A"### Cause: java.lang.NumberFormatException: For input string: "A"org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)com.sun.proxy.$Proxy83.selectOne(Unknown Source)org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)com.sun.proxy.$Proxy188.showDjRequestGcjszlyjCount(Unknown Source)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:498)org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)com.sun.proxy.$Proxy189.showDjRequestGcjszlyjCount(Unknown Source)com.qs.birp.service.impl.DjRequestGcjszlyjServiceImpl.showDjRequestGcjszlyj(DjRequestGcjszlyjServiceImpl.java:1090)com.qs.birp.service.impl.DjRequestGcjszlyjServiceImpl$$FastClassBySpringCGLIB$$1.invoke(<generated>)org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)com.qs.birp.service.impl.DjRequestGcjszlyjServiceImpl$$EnhancerBySpringCGLIB$$1.showDjRequestGcjszlyj(<generated>)com.qs.birp.controller.DjRequestGcjszlyjController.showDjRequestGcjszlyj(DjRequestGcjszlyjController.java:47)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:498)org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866)javax.servlet.http.HttpServlet.service(HttpServlet.java:635)org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)javax.servlet.http.HttpServlet.service(HttpServlet.java:742)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)com.qs.birp.config.filter.XssFilter.doFilter(XssFilter.java:36)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)com.qs.birp.config.filter.IMTAFilter.doFilter(IMTAFilter.java:37)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:96)org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:41002)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:748)

解决办法: xml里面 if 判断里面的条件判断字符串相等用双引号,外层套单引号。这是因为在比较的时候默认单引号括起来的是数字 ‘A’ 不能转化为数字 ,所以报错。

[正常情况下用字符串放在单引号里面没有问题,但如果是用==来做判断单个字符时,单引号必须改为双引号,否则会被转化为字符char格式与字符串String格式进行比较,自然就无法匹配通过]

<if test='status == "A"'> ...</if>

注意test括起来的逻辑判断 用单引号的话 全部都用单号 (如果不保持一致的话,下面的写法还是会报错)

<if test="purchase_no !=null and purchase_no !=''"> and pur_zhjj.purchase_no = #{purchase_no}</if><if test='status == "A"'> and pur_zhjj.sd_amt is null</if>