0
我有一台服务器,我添加一个服务与现有逻辑相同。所以我有这样的代码:泽西岛响应正文在客户端空身
@RolesAllowed({"authenticated", "administrator"})
@Path("notifications/{uuid}")
@Produces("application/json")
@GET
public Response getNotifications(@Context SecurityContext sc, @PathParam("uuid") String uuid) {
UserPrincipal requestingUser = (UserPrincipal) sc.getUserPrincipal();
CountNotiListItem notifications = customerService.getNotifications(requestingUser, uuid);
return Response.ok().entity(notifications).build();
}
通知对象不为空。响应被创建,并具有与其他服务相同的格式,但在客户端,我有200空的“_body”响应[_body:{}]为什么它为空?我是否应该修改更多内容以填充_body?
其实我不知道是否需要添加一些代码来序列化和反序列化。我认为我必须添加它,但随着项目已经完成(对于一个老工作),我只需要添加此服务。我不知道它是如何工作的(我从来没有与春/泽西服务合作过)。如果这是任务,请帮我把它包括在内。我向你展示每个物体的内部。 notifications =>具有4个属性的对象。 Response.ok()。entity(notifications).build()=> {entity = CountNotiListItem notifications object,entityType = me.tomsen.restapi.eib.api.CountNotiListItem,Headers = {},statustype = OK} –
Should I在“me.tomsen.restapi.eib.api.CountNotiListItem”中添加序列化和反序列化代码? –
这取决于。当其他调用正在工作时,我假设有一个JSON提供者在泽西岛注册。这很可能是包含正确注释的问题。看看正在返回的类。最有可能的@XmlRootElement – Friso