java - 怎样判断Mybatis传入参数的值
阿神
阿神 2017-04-17 16:55:15
[Java讨论组]
阿神
阿神

闭关修行中......

全部回复(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 &lt;=100000  and RN &gt;=1   
                </when>   
                <when test="_parameter != null and _parameter == '2'.toString()">    
                    RN &lt;=200000  and RN &gt;=100001   
                </when>
                <when test="_parameter != null and _parameter == '3'.toString()">    
                    RN &lt;=300000  and RN &gt;=200001   
                </when>        
                <otherwise>    
                    RN &lt;=1  and RN &gt;=1     
                </otherwise>    
            </choose>    
        </where>   
</select>
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号