码迷,mamicode.com
首页 > 数据库 > 详细

MySQL、mybatis的查询条件-时间段

时间:2016-08-12 00:43:53      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:

1.配置文件中的写法

<if test="startTime !=null and startTime !=‘‘ ">
         <![CDATA[ and createTime  >=  #{startTime}  ]]>
    </if>
    <if test="endTime !=null and endTime!=‘‘ "  >
         <![CDATA[ and createTime <=  #{endTime}  ]]>
    </if>

2.Java代码中参数的传递

》实体类中的成员变量

private Date startTime;

private Date endTime;

 

entity.setStartTime(startTime);
entity.setEndTime(endTime);

》使用map集合封装参数

Map<String, Object> map = new HashMap<String, Object>();
map.put("startTime", startTime);
map.put("endTime", endTime);

 

IT技术和行业交流群 417691667

MySQL、mybatis的查询条件-时间段

标签:

原文地址:http://www.cnblogs.com/sun-rain/p/5762982.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!