我想在一个特定的API HTTP调用传递“主机名”,“端口”,“集群”。如何传递网址中的变量? 任何帮助,非常感谢。在Java中传递API url中的变量。
代码:
\t int port = Integer.parseInt(prop.getProperty("sd.port"));
\t System.out.println("port no : " + port);
\t String hostName = prop.getProperty("sd.hostname");
\t System.out.println("host name : " + hostName);
\t
\t String cluster = app_prop.getProperty("ClusterName");
\t System.out.println("cluster name is : " + cluster);
\t
\t
\t
\t try {
\t \t
\t String url ="https://hostName:port/api/scanCluster?cid=cluster&mode=1";
在上述网址的看到,我试图通过 “主机名”, “端口” 和 “集群”。请帮忙 。
您已经使用带有'+ port','+ hostName',附加的字符串的例子'+ cluster'而且你只需要为网址做到这一点。 –