@PostMapping(value = "/updateUserInfo")
public Result updateUserInfo(@RequestBody UserInfo userInfo)  

此处的UserInfo需要实现Serializable接口,并且存在无参构造,否则无法正常接受JSON

UserInfo如下

@Data
public class UserInfo implements Serializable {
    /**
     * 手机号码
     */
    private String phone;

    /**
     * 电子邮箱
     */
    private String email;

    /**
     * 昵称
     */
    private String name;

    /**
     * 0超级用户,1管理员,2用户
     */
    private Integer oauth;

    /**
     * 0为女,1为男,3为无性别
     */
    private Integer sex;

    /**
     * 年龄
     */
    private String age;

    /**
     * 头像id
     */
    private String imgAccount;

    public UserInfo(){

    }

    public UserInfo(User user, Info info){
        this.phone = user.getPhone();
        this.email = user.getEmail();
        this.name = user.getName();
        this.oauth = user.getOauth();
        if(null!=info){
            this.sex = info.getSex();
            this.age = info.getAge();
            this.imgAccount = info.getImgAccount();
        }
    }
}

更多推荐

【踩坑】后端使用@RequestBody接受前端请求