我尝试从我的webservice获取一个json字符串,并使用此方法。
public static String getData(String serverURL) {
String Content = "no";
/************ Make Post Call To Web Server ***********/
BufferedReader reader = null;
// Send data
try {
// Defined URL where to send data
URL url = new URL(serverURL);
// Send POST data request
URLConnection conn = url.openConnection();
conn.setDoOutput(false);
// Get the server response
reader = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line = null;
// Read Server Response
while ((line = reader.readLine()) != null) {
// Append server response in string
sb.append(line + "");
}
// Append Server Response To Content String
Content = sb.toString();
} catch (Exception ex) {
System.out.println(ex);
} finally {
try {
reader.close();
} catch (Exception ex) {
System.out.println(ex);
}
}
return Content;
}
我使用
时没关系serverURL = " http://10.1.40.149:9000/api/shop/deleteshop?data={"shopId":3}";
但是当我使用
时serverURL = "http://10.1.40.149:9000/api/shop/updateshop?data={"fax":"data","tel":"data","contactTitle":"data","addr":"data","url":"data,"shopType":"data","issuedAt":"data","email":"data","shopId":data,"contactName":"data","description":"data","shopName":"data","province":"data","telNumber":"data"}";
它抛出异常
03-20 22:22:03.850: I/System.out(1117): java.io.FileNotFoundException: http://10.1.40.149:9000/api/shop/updateshop?data={"fax":"data","tel":"data","contactTitle":"data","addr":"data","url":"data,"shopType":"data","issuedAt":"data","email":"data","shopId":data,"contactName":"data","description":"data","shopName":"data","province":"data","telNumber":"data"}
任何人都可以告诉我为什么?
p / s我在网络浏览器中查看的所有链接都没问题