先上代码:
<choose> <when test="BEGINTIME != null and BEGINTIME != '' and ENDTIME != null and ENDTIME != ''"> AND time BETWEEN #{BEGINTIME, jdbcType=VARCHAR} AND #{ENDTIME, jdbcType=VARCHAR} </when> <when test="BEGINTIME != null and BEGINTIME != ''"> <![CDATA[ AND time > #{BEGINTIME, jdbcType=TIMESTAMP} ]]> </when> <when test="ENDTIME != null and ENDTIME != ''"> <![CDATA[ AND time < #{ENDTIME, jdbcType=TIMESTAMP} ]]> </when> <otherwise></otherwise> </choose> choose标签与if标签不同,前者之间是或(or)的关系,后者之间是与(and)的关系,choose标签类似于java中的switch语句choose-switch
when-case
otherwise-default
新闻热点
疑难解答