我使用Resteasy给我回电话
所以我使用界面配置我的电话
@Path("/api/private/configuracao")
public interface ConfiguracaoClient {
@GET
@Path("/")
@Consumes("application/json")
@HeaderParam(value = "db_teste")
public ConfiguracaoVO findConfiguracao();
}
并且这样打电话:
public class ConfiguracaoClientImpl {
ResteasyClient client;
ConfiguracaoClient configuracaoClient;
public ConfiguracaoClientImpl() {
client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target("http://localhost:8181/");
target.request().header("public","db_teste");
configuracaoClient = target.proxy(ConfiguracaoClient.class);
}
public ConfiguracaoVO findConfiguracao(){
return configuracaoClient.findConfiguracao();
}
}
如何在标题中添加参数? TKS
答案 0 :(得分:1)
db_teste应该是查询参数而不是标题参数。正确的语法如下:
@Path("/api/private/configuracao")
public interface ConfiguracaoClient {
@GET
@Path("/")
@Consumes("application/json")
public ConfiguracaoVO findConfiguracao(@QueryParam("db_teste") String dbTest);
}
从ConfiguracaoClientImpl
target.request().header("public","db_teste");
您可以在db_teste
来电中添加configuracaoClient.findConfiguracao(value)
的值。