有谁知道这该怎么改动啊?

img


String requestExample = "\r\nimport com.baidubce.http.ApiExplorerClient;\r\nimport com.baidubce.http.AppSigner;\r\nimport com.baidubce.http.HttpMethodName;\r\nimport com.baidubce.model.ApiExplorerRequest;\r\nimport com.baidubce.model.ApiExplorerResponse;\r\n\r\n\/\/ 号码归属查询api Java示例代码\r\npublic class RequestDemo {\r\n public static void main(String[] args) {\r\n String path = \"http:\/\/gsd.api.bdymkt.comhttp:\/\/gwgp-g8eennmvmcz.n.bdcloudapi.com\/sms\";\r\n ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);\r\n request.setCredentials(\"您的 access key\", \"您的 secret key\");\r\n\r\n request.addHeaderParameter(\"Content-Type\", \"application\/json;charset=UTF-8\");\r\n \r\n request.addQueryParameter(\"mobile\", \"\");\r\n \r\n \r\n\r\n ApiExplorerClient client = new ApiExplorerClient(new AppSigner());\r\n\r\n try {\r\n ApiExplorerResponse response = client.sendRequest(request);\r\n \/\/ 返回结果格式为Json字符串\r\n System.out.println(response.getResult());\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n }\r\n }\r\n}"; request.setJsonBody(requestExample); 

斜杠就不要转义了 ,直接 /

String requestExample = "\r\nimport com.baidubce.http.ApiExplorerClient;\r\nimport com.baidubce.http.AppSigner;\r\nimport com.baidubce.http.HttpMethodName;\r\nimport com.baidubce.model.ApiExplorerRequest;\r\nimport com.baidubce.model.ApiExplorerResponse;\r\n\r\n// 号码归属查询api Java示例代码\r\npublic class RequestDemo {\r\n public static void main(String[] args) {\r\n String path = \"http://gsd.api.bdymkt.comhttp://gwgp-g8eennmvmcz.n.bdcloudapi.com/sms\";\r\n ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path);\r\n request.setCredentials(\"您的 access key\", \"您的 secret key\");\r\n\r\n request.addHeaderParameter(\"Content-Type\", \"application/json;charset=UTF-8\");\r\n \r\n request.addQueryParameter(\"mobile\", \"\");\r\n \r\n \r\n\r\n ApiExplorerClient client = new ApiExplorerClient(new AppSigner());\r\n\r\n try {\r\n ApiExplorerResponse response = client.sendRequest(request);\r\n // 返回结果格式为Json字符串\r\n System.out.println(response.getResult());\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n }\r\n }\r\n}"; 
把你的路径里的 \ 全部写成 \\