0
我試圖從我的GWTP演示者獲取來自REST服務的響應。我的securityDelegate觸發onSuccess方法,但UserDTO似乎是空的。網絡工具向我顯示HTTP代碼爲200的請求和當前用戶的響應。出於某種原因,UserDTO似乎是空的。GWTP ResourceDelegate響應未定義
記錄儀告訴我
名稱:未定義
//LoginPresenter.java
securityDelegate.withCallback(new AsyncCallback<UserDTO>() {
@Override
public void onFailure(Throwable throwable) {
Window.alert("fail");
}
@Override
public void onSuccess(UserDTO user) {
LOGGER.info("CLASS:"+user.toString());
LOGGER.info("Name:"+user.getName());
}
}).authenticate(username,password);
//SecurityResource.java
@Path("/security")
@Produces (MediaType.APPLICATION_JSON)
@Consumes (MediaType.APPLICATION_JSON)
public interface SecurityResource {
@POST
@Path ("/authenticate")
RestAction<UserDTO> authenticate(@HeaderParam ("username") String username,@HeaderParam("password") String password);
}
//SecurityResourceImpl.java
@Path ("/security")
@Produces(MediaType.APPLICATION_JSON)
@Consumes (MediaType.APPLICATION_JSON)
public class SecurityResourceImpl {
@EJB
private SecurityBean securityBean;
@POST
@Path("/authenticate")
@Override
public Response authenticate(@HeaderParam ("username")
String username, @HeaderParam("password") String password){
User currentUser = securityBean.find(username,password);
return Response.ok().entity(new UserDTO(currentUser)).build();
}
}
//UserDTO.java
public class UserDTO implements Serializable {
private String name;
public UserDTO(){
}
public UserDTO(User user){...}
//getters/setters
}