我正在尝试从我的入口点类调用远程服务。但是,我在GWT.create((中得到错误。我正在传递服务的客户端接口。我收到错误,它必须是一个类。
19: private LoginServiceAsync loginServiceAsync = GWT.create(LoginService.class);
[错误] 第 19 行:重新绑定结果"com.example.client.LoginService"必须是类
这是我在客户端文件夹中的登录服务代码:
package com.example.client;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("LoginService")
public interface LoginService {
boolean signUpUser(String name, String email, String password);
}
谁能告诉我我做错了什么?谢谢,提前。
GWT.create(MyClass.class)
首先查找替换或生成规则。如果GWT没有找到规则,它将执行new MyClass()
。
因为您没有扩展RemoteService
,所以 GWT 找不到生成规则并尝试new
。
这就是您收到此错误的原因。
问题是我的界面没有扩展远程服务。
package com.example.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("LoginService")
public interface LoginService extends RemoteService {
boolean signUpUser(String name, String email, String password);
}
解决了我的问题,此外,我必须在LoginServiceAsync中更改它:
void signUpUser(String name, String email, String password,com.google.gwt.user.client.rpc.AsyncCallback<java.lang.Boolean> arg4);
不知道为什么会这样,任何人都可以解释一下吗?谢谢。