vue axios 传递list 后台controller写法
前台idArray=[1,2]let postData = this.qs.stringify({userIdList: idArray},{ indices: false }) //输出userIdList=5&userIdList=2this.axios({method: 'post',url: '/*****/deleteProjectByIdList',data: postDa.
·
前台
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>
更多推荐
已为社区贡献1条内容
所有评论(0)