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