你怎么写的?
应该不会有问题的,或者对方不支持post(有可能只支持doget)
应该不会有问题的,或者对方不支持post(有可能只支持doget)
解决方案 »
- struts2.xml的action中的result报错
- linux 下log4j使用,日志输出的配置
- 大虾们啊!jsp连接mysql 想将某个时间段中的数据查询出来
- 判断前台的输入是否符合规矩
- jsp页面里怎么用Cookie
- 一个jsp页面连接问题,请指教
- <option value="<%//=date()-1%>" selected>24小时内的单</option> 怎么错了?
- 救命啊!~关于存取CLOB的问题!! 在线急等!!!!!!!
- <s:if>标签传值问题
- 请问jsp实现文件下载中,为何报错java.lang.IllegalStateException: getOutputStream() has already been called for this response?(
- 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页面的时候是可以的
我现在在用程序请求的时候,可以连接到对方
只是不能获得对方网页里面显示的内容