我需要将带有自定义字段的地图传递给客户。
只是TreeMap工作正常,但不是TreeMap的后代。如果我将TreeMap更改为HashMap,它也可以正常工作。 GWT 2.5.1
public class MyMap extends TreeMap<String, String> {
public String s;
public MyMap() {
}
public MyMap(String s) {
this.s = s;
}
}
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
@Override
public Map<String, String> testSelfMap() {
Map<String, String> c = new MyMap("abc");
c.put("k", "v");
return c;
}
}
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
Map<String, String> testSelfMap();
}
public interface GreetingServiceAsync {
void testSelfMap(AsyncCallback<Map<String, String>> async);
}
public class HW implements EntryPoint {
GreetingServiceAsync serv = GWT.create(GreetingService.class);
public void onModuleLoad() {
serv.testSelfMap(new AsyncCallback<Map<String, String>>() {
@Override
public void onSuccess(Map<String, String> result) {
System.out.println(result.get("k"));
}
@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
}
});
}
}