http://somecompany.com/restws/ebi/SVI/4048/?Name=Tra&Brand=Software: WebSphere - Open App Servers
我傳遞一個URL看起來它不喜歡的第二個參數(品牌)。從瀏覽器上面這個查詢字符串工作正常,但只要我在Java中執行,它失敗。當我改變了網絡服務來接受一個單一的參數,那麼這個URL工作正常
http://somecompany.com/restws/ebi/SVI/4048/?Name=Tra
看來Java是具有第二個參數的問題。我試過了逃生角色和其他所有我能想到的東西,但似乎沒有任何工作。請幫忙!
String uri = "somecompany.com/restws/ebi/SVI/4048/?Name="
+ name+ "&Brand=Software: WebSphere - Open App Servers";
URL url;
try {
url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/xml");
}
...
我希望它的錯字,但在你的代碼中,我不相信你應該有字符串uri包含「websphere-open app servers」如果它不是錯字,希望它很容易修復 – GK1667 2012-07-31 14:25:11