mybatis中關於引數map和結果集map的 處理
阿新 • • 發佈:2019-01-24
@Test
public void findmap() {
Map map=new HashMap<>();
map.put("username", "老王");
/* u.username ='老王';*/
List<Map<String,Object>> map1=mapper.findmap(map);
//轉換成json資料返回給前端頁面
System.out.println(map1.size());
System.out.println(map1);
}
<!-- if條件判斷的時候要判斷的是 最後的一層 其實就是盤但 要用到的 .此時寫map!=null是不對的原因是此時的引數型別是型別不是具體的某個值 -->
<!-- 是值的判定而不是型別的判定 型別不能未null吧 -->
<select id="findmap" parameterType="map" resultType="map">
SELECT * from user u inner JOIN user_role ur on u.id=ur.UID join role r on ur.RID=r.ID
<where>
<if test="username !=null">
and u.username=#{username}
</if>
</where>
</select>
public void findmap() {
Map map=new HashMap<>();
map.put("username", "老王");
/* u.username ='老王';*/
List<Map<String,Object>> map1=mapper.findmap(map);
//轉換成json資料返回給前端頁面
System.out.println(map1.size());
System.out.println(map1);
}
<!-- if條件判斷的時候要判斷的是 最後的一層 其實就是盤但 要用到的 .此時寫map!=null是不對的原因是此時的引數型別是型別不是具體的某個值 -->
<!-- 是值的判定而不是型別的判定 型別不能未null吧 -->
<select id="findmap" parameterType="map" resultType="map">
SELECT * from user u inner JOIN user_role ur on u.id=ur.UID join role r on ur.RID=r.ID
<where>
<if test="username !=null">
and u.username=#{username}
</if>
</where>
</select>