问题:sqlserver中的存储时间格式为date,pojo的时间属性也是date,直接mybatis取出的时间格式是带英语的那种,不满足客户要求。
解决:将pojo的时间属性改为string类型,在mybatis的配置sql语句文件中,将得到的date格式的时间转换成string
直接在xml配置文件中,在收到 date 字段后面加上jdbcType="VARCHAR"
<resultMap type="com.soecode.lyf.entity.AuditPage" id="AuditPageList">
<id column="id" property="id" />
<result column="inputdate" property="date" jdbcType="VARCHAR" />
<result column="checkid" property="number" />
<result column="proceedingname" property="name" />
<result column="isapproved" property="zt" />
</resultMap>
<select id="getAllAudit" resultMap="AuditPageList" >
select top 20 id,inputdate,checkid,
proceedingname,isapproved
from exm001 order by inputdate desc
</select>
本文解决在使用MyBatis框架时,从SQL Server数据库获取的日期格式不符合客户需求的问题。通过将POJO时间属性改为String类型,并在XML配置文件中进行相应设置,成功将日期转换为指定格式。
2077

被折叠的 条评论
为什么被折叠?



