//中文必须在URLEncoder后传递,编码为gb2312
String content = java.net.URLEncoder.encode("您本次操作的短信验证码为"+code,"gb2312");
//拼接访问短信接口的url
String sendUrl = "http://si.800617.com:4400/SendSms.aspx?un="+uname+"&pwd="+pwd+"&mobile="+clientTel+"&msg="+content;
System.out.println(sendUrl);
URL url = new URL(sendUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("GET");
connection.connect();
String result = "";
InputStreamReader bis = new InputStreamReader(connection.getInputStream(),"gb2312");
int c = 0;
while((c = bis.read()) != -1){
result = result + (char)c;
}
return result;
执行的时候,总是报Server returned HTTP response code: 411 for URL的错误,一开始是报Server returned HTTP response code: 400 for URL的错误,后来URLEncoder.encode设置编码以后就报411的错了,本以为还是中文的问题,后把connection.setRequestMethod("GET");改成GET的就可以,之前是POST。
分享到:
相关推荐
java.io.IOException: Server returned HTTP response code: 403 for URL 处理过程记录 BASIC AUTH2 POST接口,解决403问题
429问题处理办法(悟用书生)
声明 1、本解决方法适用于浏览器正常访问,但是代码请求报错Http 403错误的场景; 概述: 1、Http 403报错是常见的网络错误提示,表示...报错Server returned HTTP response code 403 for URL.txt》里面的内容操作。
m3u8是一种媒体播放列表格式,它包含...5.2、解决报错:Server returned HTTP response code: 403 for URL。 若下载下来有合并需求的,可以看下合并工具:https://download.csdn.net/download/gongjin28_csdn/35906117
java was started but returned exit code=1; 关于Android最新的SDK下载解压后出现java was started but returned exit code=1;时的解决方法,我在网上参考相关文献后得出的,希望对你有用!
git首次提交代码到远程仓库提示413错误,错误信息如下 git push --set-upstream origin master Enumerating objects: 153, done. ... HTTP 413 curl 22 The requested URL returned error: 413 Req
在Java编程环境中,有时我们...通过定义Java接口、加载DLL、创建接口实例和调用函数,你可以轻松地在Java项目中利用DLL的功能。然而,为了确保程序的稳定性和安全性,务必了解DLL函数的内部实现和可能的错误处理策略。
如果在部署时出现 `Server returned HTTP response code: 403` 异常,可能是因为 Tomcat 7 引用的角色是 `manager-script` 而不是 `manager`,或者 Tomcat 7 对于部署(deploy)需要的角色应该是 `manager-script` ...
apt-get 安装失败,提示E Sub-process usrbindpkg returned an error code 解决办法 :
Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Table of Contents If you're viewing this document online, you can click any of the topics below to link ...
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running FusedConv node. Name:'Conv_461_Add_463_Relu_464' Status Message: CUDNN ...
在安装Net Framework 3.0 时安装错误,报Windows Presentation Foundation: [2] Error: ... MSI returned error code 1603等错误,原因是由于使用的是GHOST XP系统,按文档方法可以解决,无需重装系统,亲测
curl: (22) The requested URL returned error: 404 Not Found Error: An exception occurred within a child process: DownloadError: Failed to download resource “ant–bcel” 经过查看,homebrew寻找的该软件...
lingo 错误代码最全的已经更新至9.0版本的错误代码。方便经常用lingo的人查询错误。
MyEclipse2015 Stable1.0 刚出我们就尝到了鲜肉,费话不多说,速速分享给你们! 之前遇到Java was started but returned code=-1,还以为是jdk配置的有问题,其实不是,注册破解就好了。
在Unity引擎中调用Java代码,通常是通过与Android原生平台进行交互来实现的,这在游戏开发或者需要利用特定Android功能时非常有用。本文将详细介绍如何在Unity中调用JAR包的方法和属性。 首先,我们需要一个包含所...
Android下通过root实现对system_server中binder的ioctl调用拦截
标题中的“Microsoft Visual 14.0 amd64 C++ Build Tools.7z”指的是微软提供的Visual C++ 14.0编译工具的64位版本,它被压缩成7z格式的文件,便于下载和存储。这个工具集是微软Visual Studio 2015的一部分,用于...
HttpClient response nullprivate static void close(HttpMethod method) {method.rel