我尝试将 ArrayList 发送到 GWT 中的 RPC 服务,但始终失败。 这是我的代码片段
greetingService.addNewQuestion(questionnaireKey, questionText, qcList, new AsyncCallback<Boolean>(){
@Override
public void onFailure(Throwable caught) {
Window.alert("Something went wrong!\n"+caught.getMessage());
}
@Override
public void onSuccess(Boolean result) {
Window.alert("Question Added!");
}
});
QuestionChoice是一个没有方法的简单对象,qcList是QuestionChoice的ArrayList
public class QuestionChoice implements IsSerializable{
/**
*
*/
private static final long serialVersionUID = 5668640935838672293L;
public String text;
public boolean isCorrect;
public QuestionChoice(){
}
public QuestionChoice(String text, boolean isCorrect){
this.text = text;
this.isCorrect = isCorrect;
}
}
有人尝试过在 GWT-RPC 中发送 ArrayList 作为参数吗? 如果您这样做,请尝试在此处发布您的示例代码。 谢谢。
最佳答案
是的,可以在 GWT-RPC 调用中发送 ArrayList 作为参数。在开发GWT-RPC代码时,很多时候调用GWT-RPC中的请求时可能会遇到错误,这是由于GWT-RPC服务发生了变化,可能与客户端编译的GWT-RPC不对应定义。要解决此问题,每当您更改服务器端类或 GWT-RPC 服务定义(即 GreetingService、GreetingServiceAsync 和 GreetingServiceImpl)中的代码时,您都必须重新启动开发服务器
关于gwt - 在 GWT-RPC 中发送 ArrayList 作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1925821/