Code Bye

myBatis3异常提示For input string: "{0=null}"

 

求大神解决,我找遍了互联网都没找到有人有提出这个。

问题:mybatis3+S2+S3在insert时候报异常:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.lang.NumberFormatException: For input string: “{0=null}”
### Cause: java.lang.NumberFormatException: For input string: “{0=null}”
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible
(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at $Proxy5.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:237)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:79)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
at $Proxy8.insertFuncGroup(Unknown Source)
at com.gt.jwzh.service.impl.FuncGroupServiceImpl.addFuncGroup(FuncGroupServiceImpl.java:102)
at com.gt.jwzh.service.impl.FuncGroupServiceImpl$$FastClassByCGLIB$$bbcece90.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.gt.jwzh.service.impl.FuncGroupServiceImpl$$EnhancerByCGLIB$$47e0e52.addFuncGroup(<generated>)
at com.gt.jwzh.action.SaveFuncGroup.execute(SaveFuncGroup.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
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:128)
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:293)
….

—————————-
配置文件:
<resultMap type=”FuncGroup” id=”funcGroupResultMap”>
<id property=”funcGroupID” column=”FUNCGROUPID” javaType=”long” />
<result property=”appID” column=”APPID” javaType=”long” />
<result property=”funcGroupName” column=”FUNCGROUPNAME” javaType=”string” />
<result property=”parentGroup” column=”PARENTGROUP” javaType=”long” />
<result property=”groupLevel” column=”GROUPLEVEL” javaType=”int” />
<result property=”funcGroupSEQ” column=”FUNCGROUPSEQ” javaType=”string” />
<result property=”isLeaf” column=”ISLEAF” javaType=”string”/>
<result property=”subCount” column=”SUBCOUNT” javaType=”long” />
</resultMap>

<insert id=”insertFuncGroup” parameterType=”FuncGroup”>
<choose>
<when test=”#{parentGroup} == 0″>
<![CDATA[
INSERT INTO XTGL.AC_FUNCGROUP(FUNCGROUPID, APPID, FUNCGROUPNAME, GROUPLEVEL, FUNCGROUPSEQ, ISLEAF, SUBCOUNT) 
VALUES(#{funcGroupID}, #{appID}, #{funcGroupName}, #{groupLevel}, #{funcGroupSEQ}, #{isLeaf, jdbcType=VARCHAR}, #{subCount})
]]>
</when>
<otherwise>
<![CDATA[
INSERT INTO XTGL.AC_FUNCGROUP(FUNCGROUPID, APPID, FUNCGROUPNAME, GROUPLEVEL, FUNCGROUPSEQ, ISLEAF, SUBCOUNT) 
VALUES(#{funcGroupID}, #{appID}, #{funcGroupName},#{groupLevel}, #{funcGroupSEQ}, #{isLeaf, jdbcType=VARCHAR}, #{subCount})
]]>
</otherwise>
</choose>
</insert>

—————————–
Java有关代码:
private FuncGroupService funcGroupService;
private long funcGroupID;
private String funcGroupName;
private long parentGroup;

@Override
public String execute() throws Exception {
funcGroupName = URLDecoder.decode(funcGroupName, “UTF8”); //解码为UTF8
if(!funcGroupService.addFuncGroup(funcGroupID, funcGroupName, parentGroup, logger)){
session.put(“errorInfo”, “FuncGroup保存失败”);
return “fail”;
}
return “success”;
}
————————-

问题处在FuncGroup的parentGroup这个属性上,
我也出现了这样的错误,求大神解决

18分
找了很久终于解决了,在<when test=””></when>标签中接收参数的时候test中去掉#{}直接写上参数的名称就可以了<if test=””></if>也是一样!

2分
3楼的正确,同时如果参数是map<String,Date>的话,也要用#{}进行去数据,不能用${}

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明myBatis3异常提示For input string: "{0=null}"