首先在Controller中选取想要的数据(checkLocation, userId),然後再把数据put进context
Map<String, String> context = new HashMap<>();
context.put("checkLocation", checkLocation);
context.put("userId", userId);
RpcContext.getContext().setAttachments(context);
在implement中,初始化两个数据
String checkLocation = "";
String userId = "";
初始化对象
RpcContext rpcContext = RpcContext.getContext();
注意为空判断,getAttachment获取到数据
if (null != rpcContext) {
checkLocation = rpcContext.getAttachment("checkLocation");
userId = rpcContext.getAttachment("userId");
}