我想在 Java 中调用一系列 API 调用。要求是在后续的 API 调用请求中会用到一些 API 的响应。我可以使用某些循环来实现这一点。但我想以实现通用的方式使用设计模式。有什么帮助吗?
责任链不能满足我的需要,因为一开始我不知道我的请求上下文是什么。
String out = null;
Response res = execute(req);
out += res.getOut();
req.setXYZ(res.getXYZ);
Response res = execute(req);
out += res.getOut();
req.setABC(res.getABC);
Response res = execute(req);
out += res.getOut();
System.out.println("Final response::"+out);
Run Code Online (Sandbox Code Playgroud) 如何为HttpServletRequestInterface 创建对象?
HttpServletRequest是一个接口,但仍然是servlet容器可以创建相同的对象.怎么样?为什么?