axios传递数组以及对象,后端接收

2023-11-27 15:29:41 浏览数 (1)

前端代码:

代码语言:javascript复制
 insertRole() {
        let data = {
         role:{
           rname: "业务员",
           remark: "业务员",
         },
          pids: [1, 2, 3, 4]
        }
        this.$axios.post(this.$api   "role/insertRole", data,{indices:false,headers:{'Content-Type':'application/json'}}).then().catch(err => {
          console.log(err);
        })
      }

后端代码:

代码语言:javascript复制
@PostMapping("/role/insertRole")
    @ApiOperation(value="添加角色",notes="添加角色")
    public void insertRole(@RequestBody RoleVo role){
        System.out.println(role);
    }

实体:

代码语言:javascript复制
@Getter
@Setter
@ToString
public class RoleVo {
    private Role role;
    private List<Integer> pids;
}

0 人点赞