我目前正在尝试获取可能支持多个重定向的资源。我的代码如下所示:
Client client = new Client(new Context(), Protocol.HTTP);
Context ctx = client.getContext();
ctx.getParameters().add("followRedirects", "true");
ClientResource cr = new ClientResource(ctx,u);
Representation r = cr.get();
但是不遵循重定向。我做错了什么?
这是 Google App Engine 上的 ReSTLet 2.1
最佳答案
Series<Parameter> params = ctx.getParameters();
params.add("followRedirects", "true");
ctx.setParameters(params);
关于java - 如何让 reSTLet 遵循 301 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21497705/