gomap_controller.java
List<String> room = new ArrayList<String>();
Map searchConditions = new HashMap<>();
searchConditions.put("room", room);
List<Map> rList = rd.getRoomList(searchConditions);
室温mapper.xml
<select id="getRoomList" resultType="java.util.HashMap"
parameterType="java.util.HashMap">
<choose>
<when
test="underground != '' or low_floor != '' or mid_floor != '' or high_floor != ''">
B_FLOOR IN
<foreach collection="room" item="item" index="index"
separator="," open="(" close=")AND">
#{item}
</foreach>
</when>
</choose>
现在我收到错误###错误查询数据库。原因:org.apache.ibatis.builder.BuilderException:表达式&#39; room&#39;评估为空值。
答案 0 :(得分:0)
您在测试中没有评估空集合。看起来您正在对地图中的键执行验证?基于你在那里的一小段代码,我希望看到这个评价而不是你所拥有的......
SELECT ...
FROM ...
<choose>
<when test="room" != 'null'>
WHERE B_FLOOR IN
<foreach collection="room" item="item" index="index" separator="," open="(" close=")AND">
#{item}
</foreach>
</when>
</choose>