我写了一个自定义的 RpcRequestBuilder 来进行身份验证,就像这样:
http://stuffthathappens.com/blog/2009/12/22/custom-http-headers-with-gwt-rpc
但我需要每个 GWT RPC 服务在使用之前设置我的自定义构建器,或者如果可能的话,告诉 GWT 使用我的版本作为默认版本。我该怎么做?
最佳答案
public static final UtilServiceAsync getInstance() {
if (instance == null) {
instance = (UtilServiceAsync) GWT.create(UtilService.class);
ServiceDefTarget target = (ServiceDefTarget) instance;
RpcRequestBuilder reqBuilder = new RpcRequestBuilder() {
@Override
protected RequestBuilder doCreate(String serviceEntryPoint) {
RequestBuilder rb = super.doCreate(serviceEntryPoint);
rb.setHeader("HEADER_SIGNATURE", "your token");
return rb;
}
};
target.setRpcRequestBuilder(reqBuilder);
//target.setServiceEntryPoint(GWT.getModuleBaseURL() + "springGwtServices/" + "utilService");
}
return instance;
}
关于security - 我如何更改默认的 RpcRequestBuilder?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4556669/