Mybatis 异常: The content of elements must consist of well-formed character data or markup

解决MyBatis配置中使用小于号导致的Tomcat启动异常
本文详细介绍了在使用MyBatis时遇到的配置问题,即在配置文件中出现小于号导致的SAXParseException异常,并通过修改条件语句解决了Tomcat无法启动的问题。

今天用mybatis弄一个小玩意,发现Mapper中以下语句报错,且会导致Tomcat无法正常启动

<select id="getAmountByTimePeriod"  resultMap="seatHisAmountMap">
        select
        sum(nightFare) as nightAmount ,    sum(fare) as seatAmount ,#{0} as starttime,
        #{1} as endtime
        from nightfare
        where
          endtime >=#{0}
        and
          endtime <=#{1}
    </select>

异常如下:
     SAXParseException: The content of elements must consist of well-formed character data or markup.

百度一下得到一个匪夷所思的答案:

     记住:在ibatis的配置文件中不能出现小于号

抱着试试看的态度试验了一下,代码改为:

<select id="getAmountByTimePeriod"  resultMap="seatHisAmountMap">
        select
        sum(nightFare) as nightAmount ,    sum(fare) as seatAmount ,#{0} as starttime,
        #{1} as endtime
        from nightfare
        where
          endtime >=#{0}
        and
          #{1}>=endtime 
    </select>

问题竟然解决了....

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值