前台 
idArray=[1,2]
let postData = this.qs.stringify({
          userIdList: idArray
        },{ indices: false }) //输出userIdList=5&userIdList=2
this.axios({
          method: 'post',
          url: '/*****/deleteProjectByIdList',
          data: postData
        })
# 请求URL http://127.0.0.1:8080/deleteProjectByIdList?userIdList=1&userIdList=2


controller
@RequestMapping(value = "/deleteProjectByIdList")
	@ResponseBody
	public Integer deleteProjectByIdList(int[] userIdList) {

		ArrayList<Object> list = new ArrayList<>();
		for (int projectId : userIdList) {
			System.out.println(projectId);
			list.add(projectId);
		}
		return projectService.deleteProjectByIdList(list);
	}
mapper.xml
 <delete id="deleteProjectByIdList" parameterType="java.util.List">
        delete from projectinfo where id in
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">#{item,jdbcType=VARCHAR}
        </foreach>
    </delete>

 

Logo

前往低代码交流专区

更多推荐