Java Rest PUT 500请求失败

时间:2018-08-12 14:42:36

标签: java rest jersey eclipselink moxy

当前,我在PUT上苦苦挣扎,总是收到500个请求失败。

Screenshot of the Problem

用户

    {"id": 3,
    "firstname": "lmao",
    "lastname": "test",
    "username": "test",
    "password": "test",
    "created": "2018-08-12",
    "locks": []
    }

来源

@PUT
@Path("user/{id}")
@Consumes(MediaType.APPLICATION_JSON)
public void editUser(@PathParam("id") int id, User u) {
    long i = (long) id;
    u.setId(i);
    rep.updateUser(u);
}

存储库

public void updateUser(User u) {
    User user = (User) em.find(User.class, u.getId());
    if (user != null) {
        user = u;
        em.getTransaction().begin();
        em.refresh(user);
        em.getTransaction().commit();
    }
}

0 个答案:

没有答案