import java.net.*;
import java.io.*;public class post{
public static void main(String[] args) throws IOException{
URL url=new URL("http://127.0.0.1/index.asp");//aaaaa
String query="T1=2005-5-5&B1=查询";
URLConnection uc=url.openConnection();
uc.setDoOutput(true);
OutputStreamWriter out=new OutputStreamWriter(uc.getOutputStream(),"ASCII");
out.write(query);
out.write("\r\n");
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String line;
while ((line=in.readLine()) != null){
System.out.println(line);
}
}
}
用IE访问http://127.0.0.1/index.asp时,点查询按钮后,会把T1参数传递过去,服务器端根据T1的日期发回不同日期的数据在网页上。我在java程序里把T1以及查询按钮B1的值都post给服务器,可为什么得不到T1日期的数据呢?我看不到服务器端的程序所以感觉很麻烦。大家帮我想想是怎么回事?用get方式传递参数也不行。
import java.io.*;public class post{
public static void main(String[] args) throws IOException{
URL url=new URL("http://127.0.0.1/index.asp");//aaaaa
String query="T1=2005-5-5&B1=查询";
URLConnection uc=url.openConnection();
uc.setDoOutput(true);
OutputStreamWriter out=new OutputStreamWriter(uc.getOutputStream(),"ASCII");
out.write(query);
out.write("\r\n");
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String line;
while ((line=in.readLine()) != null){
System.out.println(line);
}
}
}
用IE访问http://127.0.0.1/index.asp时,点查询按钮后,会把T1参数传递过去,服务器端根据T1的日期发回不同日期的数据在网页上。我在java程序里把T1以及查询按钮B1的值都post给服务器,可为什么得不到T1日期的数据呢?我看不到服务器端的程序所以感觉很麻烦。大家帮我想想是怎么回事?用get方式传递参数也不行。
解决方案 »
- Object的hashCode()和equals()有什么关系吗?
- 求一条语句的执行流程
- 弱弱的问:怎么输出双引号??
- Connection关闭时报错
- 高分求内部类的问题
- 帮我看段代码? 大虾帮帮忙,郁闷了很久了
- java中怎样实现象C++中一样使用print输出格式,如print("%ld",i)
- asp和java组件的问题,高手请赐教啊!
- 請推薦好用的Application server. (現在計劃用JSP + Java + Oracle開發) ~有用意見給100分~
- 在applet中如何加入菜单???
- java.util.Properties 类中store(OutputStream out, String header) 的方法如何用?
- 请教用URLConnection访问web服务器的问题?
有没有
uc.setDoInput(true);