MyBatis小知识点

mac2026-06-11  12

1. 前端传值"null",需要mybatis比较

<if test="dwid!=null"> and jq.dwid <![CDATA[ <=> ]]> ${dwid} </if>

2. Mybatis可以传入时间类型

不过不建议这样写,可以直接使用mysql时间函数now()

<select id="selectByDate" resultMap="BaseResultMap" parameterType="java.util.Date" > select <include refid="Base_Column_List" /> from t_xs_shxszje <where> <if test="date!=null and date!=''"> and date_format(sj,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d') </if> </where> </select>

 

最新回复(0)