The error is occurring because the JSON object is being cast to the wrong type. Instead of casting it to SysUser, it is being cast to LinkedHashMap.

To fix this issue, you need to convert the JSON object to the SysUser object manually. Here's an example of how you can do it:

public AjaxResult addUser(@Validated @RequestBody JSONObject object) {
    Long id = (Long) object.get("id");
    JSONObject userObject = (JSONObject) object.get("user");

    SysUser user = new SysUser();
    user.setUserName(userObject.getString("userName"));
    user.setPhonenumber(userObject.getString("phonenumber"));
    user.setEmail(userObject.getString("email"));
    user.setNickName(userObject.getString("nickName"));
    user.setPassword(userObject.getString("password"));
    user.setSex(userObject.getString("sex"));
    user.setStatus(userObject.getString("status"));

    // Rest of the code...
}

In this code, the userObject is extracted from the JSON object, and its properties are used to set the corresponding properties of the SysUser object manually

id15 useruserNameM0016701phonenumber15914759321email nickName长布镇人员passwordM0016701sex0status0 后端接受格式 public AjaxResult addUserValidated RequestBody JSONObject object Long id=Long objec

原文地址: http://www.cveoy.top/t/topic/iLYl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录