怎样判断Mybatis传入参数的值
1个回答
展开全部
在MyBatis的xml中替换成了when标签,并且在判断时,将判断的值加上toString(),参数名为_parameter,不需要指定成传入的参数名,参考代码如下:
<select id="getLoop" resultMap="AAA" parameterType="String">
SELECT *, ROWNUM RN from tablename
<where>
<choose>
<when test="_parameter != null and _parameter == '1'.toString()">
RN <=100000 and RN >=1
</when>
<when test="_parameter != null and _parameter == '2'.toString()">
RN <=200000 and RN >=100001
</when>
<when test="_parameter != null and _parameter == '3'.toString()">
RN <=300000 and RN >=200001
</when>
<otherwise>
RN <=1 and RN >=1
</otherwise>
</choose>
</where>
</select>
<select id="getLoop" resultMap="AAA" parameterType="String">
SELECT *, ROWNUM RN from tablename
<where>
<choose>
<when test="_parameter != null and _parameter == '1'.toString()">
RN <=100000 and RN >=1
</when>
<when test="_parameter != null and _parameter == '2'.toString()">
RN <=200000 and RN >=100001
</when>
<when test="_parameter != null and _parameter == '3'.toString()">
RN <=300000 and RN >=200001
</when>
<otherwise>
RN <=1 and RN >=1
</otherwise>
</choose>
</where>
</select>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询