美文网首页
<,>引起的mybatis异常:元素内容必须由格式正

<,>引起的mybatis异常:元素内容必须由格式正

作者: cat昵称居然被占用了 | 来源:发表于2016-12-21 20:40 被阅读820次

错误示例:

  select
    id,
   channel,
    if(txntime='', createtime, STR_TO_DATE(txntime, '%Y%m%d%H%i%s')) onDate,
    feeType,
    amount bizAmount,
    ROUND((case platform when '8' then if(amount*0.002<1,1,amount*0.002) when '6' then amount*0.003 else amount*0.003 end),2)  fee,
    't_union_order' refType,
    id refValue,
    '' memo,
    isDeprecated,
    createTime,
    lastUpdateTime
    from t_order

错误原因:mybatis查询的时候,需要用到运算符 小于号:< 和 大于号: >,在mybatis配置文件里面,这种会被认为是标签,所以解析错误.

解决方法,用<![CDATA[ ]]>将有<,>的代码包起来。
如下:

select
    id,
   channel,
    if(txntime='', createtime, STR_TO_DATE(txntime, '%Y%m%d%H%i%s')) onDate,
    '用户还款' feeType,
    amount bizAmount,
    <![CDATA[ROUND((case platform when '8' then if(amount*0.002<1,1,amount*0.002) when '6' then amount*0.003 else amount*0.003 end),2)]]> fee,
    't_union_order' refType,
    id refValue,
    '' memo,
    isDeprecated,
    createTime,
    lastUpdateTime
    from t_order

相关文章

网友评论

      本文标题:<,>引起的mybatis异常:元素内容必须由格式正

      本文链接:https://www.haomeiwen.com/subject/pctcvttx.html