java将2个字符串放在一起以使用ResultSet构建URL
我正在尝试从结果集中的两部分构建url。Prop_值本身只是一个URL,但我需要在它的末尾添加一个venu项。以下是我涉及构建的代码:
String first = (rs1.getString("PROP_VALUE"));
String second = (rs1.getString("VEN_ITEM"));
String url = (first+second);
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
int responseCode = con.getResponseCode();
System.out.println("\nSending 'GET' request to URL : " +url);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
con.disconnect();
它将运行,但它只发送PROP_值,而不将venu项附加到它,有什么建议吗
# 1 楼答案
我认为第一个和第二个变量值有问题。请查收。Bcoz,下面的代码运行良好
已获得以下控制台输出: