<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [MyBatis傳入多個參數的問題](http://www.tuicool.com/articles/q2mui2) [TOC=1,3] **一、單個參數:** public ListXXBean> getXXBeanList(String xxCode); select id="getXXXBeanList" parameterType="java.lang.String" resultType="XXBean"> select t.* from tableName t where t.id= #{id} select> 其中方法名和ID一致,#{}中的參數名與方法中的參數名一直, 我這里采用的是XXXBean是采用的短名字, select 后的字段列表要和bean中的屬性名一致, 如果不一致的可以用 as 來補充。 **二、多參數:** public ListXXXBean> getXXXBeanList(String xxId, String xxCode); select id="getXXXBeanList" resultType="XXBean"> select t.* from tableName where id = #{0} and name = #{1} select> 由于是多參數那么就不能使用parameterType, 改用#{index}是第幾個就用第幾個的索引,索引從0開始 **三、Map封裝多參數:**?? public ListXXXBean> getXXXBeanList(HashMap map); select id="getXXXBeanList" parameterType="hashmap" resultType="XXBean"> select 字段... from XXX where id=#{xxId} code = #{xxCode} select> 其中hashmap是mybatis自己配置好的直接使用就行。map中key的名字是那個就在#{}使用那個,map如何封裝就不用了我說了吧。 **?四、List封裝in:** public ListXXXBean> getXXXBeanList(ListString> list); select id="getXXXBeanList" resultType="XXBean"> select 字段... from XXX where id inforeach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item}foreach> select> foreach 最后的效果是select 字段... from XXX where id in ('1','2','3','4') **五、多參數傳遞之注解方式示:**?? ? 例子: public AddrInfo getAddrInfo(@Param("corpId")int corpId, @Param("addrId")int addrId); xml配置這樣寫: select id="getAddrInfo" resultMap="com.xxx.xxx.AddrInfo"> SELECT * FROM addr__info     where addr_id=#{addrId} and corp_id=#{corpId} select> 以前在select>語句中要帶parameterType的,現在可以不要這樣寫。 **六、selectList()只能傳遞一個參數,但實際所需參數既要包含String類型,又要包含List類型時的處理方法:** 將參數放入Map,再取出Map中的List遍歷。如下: ListString> list_3 = new ArrayListString>(); MapString, Object> map2 = new HashMapString, Object>(); list.add("1"); list.add("2"); map.put("list", list); //網址id map.put("siteTag", "0");//網址類型 public List getSysInfo(MapString, Object> map2) {return getSqlSession().selectList("sysweb.getSysInfo", map2); } select id="getSysInfo" parameterType="java.util.Map" resultType="SysWeb"> select t.sysSiteId, t.siteName, t1.mzNum as siteTagNum, t1.mzName as siteTag, t.url, t.iconPath from TD_WEB_SYSSITE t left join TD_MZ_MZDY t1 on t1.mzNum = t.siteTag and t1.mzType = 10 WHERE t.siteTag = #{siteTag } and t.sysSiteId not in foreach collection="list" item="item" index="index" open="(" close=")" separator=","> #{item} foreach> select>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看