你怎么写的?
应该不会有问题的,或者对方不支持post(有可能只支持doget)
应该不会有问题的,或者对方不支持post(有可能只支持doget)
解决方案 »
- 最近做了个SSH项目,但是还是没有体会到Spring的好处!欢迎大家来讨论下哈!
- 使用outlook发送本页
- 我类用JFreeChart生报表,iText将报表放入PDF里,怎么将PDF通过servlet传入html页面里
- MyEclipse插件的小问题
- 怎么实现页面上的下载功能?
- 详细说一下jcf框架中的一些概念
- 简单的servlet问题,请大家帮忙!
- 在线浏览excel文件出现乱码(tomcat服务器)
- 300用户同时访问网站,CPU和内存应该是什么样的?(ASP开发数据库ORACLE)100分
- springmvc 关于表单的保存问题····在线等
- tomcat出现404错误,求助!急
- 如何在IE中直接打开CSV文件?
HttpURLConnection httpConn=null;
FileInputStream fin = null;
OutputStream out = null;
InputStreamReader isr = null;
BufferedReader in = null;
try {
//与商户建立一个连接
URL url = new URL(Url);
//打开连接
httpConn = (HttpURLConnection) url.openConnection();
fin = new FileInputStream(xmlFile2Send);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
copy(fin, bout);
byte[] b = bout.toByteArray();
httpConn.setRequestProperty("Content-Length", String.valueOf(b.length));
//以xml格式传送
httpConn.setRequestProperty("Content-Type", "text/xml; charset=GB2312");
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
out = httpConn.getOutputStream();
out.write(b);
out.flush();
httpConn.connect();
//获取输入流
isr = new InputStreamReader(httpConn.getInputStream());
in = new BufferedReader(isr);
StringBuffer buf = new StringBuffer();
String inputLine;
while ( (inputLine = in.readLine()) != null)
{
buf.append(inputLine);
} if (buf.toString().trim().equalsIgnoreCase("ok")) {
Tools.trace(buf.toString().trim());
flag=true;
}
else {
flag=false;
} }catch (MalformedURLException ex) {
Tools.error(ex);
}
catch (IOException ex) {
Tools.error(ex);
}
finally {
//关闭操作
Tools.closeBufferedReader(in);
Tools.closeInputStreamReader(isr);
Tools.closeOutputStream(out);
Tools.closeFileInputStream(fin);
Tools.closeHttpURLConnection(httpConn);
}
return flag;
}
并且直接请求web页面的时候是可以的
我现在在用程序请求的时候,可以连接到对方
只是不能获得对方网页里面显示的内容