一、前端多选 传字符串类型给后端,用逗号(,)分隔开
后端用String类型接收该字段
/**
* 所属部门编码list
*/
@ApiModelProperty(name = "departmentCodeList", value = "所属部门编码集")
private String departmentCodeList ;
mybatis中写法如下:
<if test="vo.departmentCodeList != null and vo.departmentCodeList != ''">
AND r.department_code in
<foreach item="departmentCode" collection="vo.departmentCodeList.split(',')" open="(" separator="," close=")">
#{departmentCode}
</foreach>
</if>
二、前端用list形式传给后端
后端用List形式接收
@ApiModelProperty(name = "departmentCodeLists", value = "所属部门编码集")
private List<String> departmentCodeLists ;
mybatis中写法:
<if test="vo.departmentCodeLists != null and vo.departmentCodeList.size>0">
AND r.department_code in
<foreach collection="vo.departmentCodeLists" item="departmentCode" index="index" open="(" close=")" separator=",">
#{departmentCode}
</foreach>
</if>
注意:在接受list的时候不能加该判断: list!=‘’ , 换成判断list.size>0
标签:xml,编码,code,list,private,用法,departmentCodeLists,Mybatis From: https://www.cnblogs.com/marchxd/p/17761750.html