关于java.net.URL URL url=new URL(urlString);//urlString好像不能带参数,比如urlString="http://192.168.1.186/index.jsp?flag=1",参数flag=1传不过去,请问如何解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 I don't konw, but please show me the error message... Firstly, "." and "?" need escape character... 我试了一下..可以传过去啊..你试着把你URL url=new URL(urlString);这个的 url打印出来你就能看到了. 我打印出来是 完整的..有参数. import java.net.*;import java.io.*;import java.util.*;public class TestURL { public static void main(String[] args) throws Exception { URL url = new URL("http://localhost:9999/cms/cms/website/test3/index.jsp?siteId=11"); URLConnection urlcon = url.openConnection(); System.out.println("UrlContent TimeOut:"+urlcon.getConnectTimeout()); System.out.println("UrlContent LastModified:"+new Date(urlcon.getLastModified())); int i = urlcon.getContentLength(); byte[] b=new byte[99999]; System.out.println(i); File file=new File("d:\\test.html"); FileOutputStream writer=new FileOutputStream(file); if(i>0){ InputStream is = urlcon.getInputStream(); is.read(b); writer.write(b); is.close(); writer.flush(); writer.close(); }else{ System.out.println("Length is null."); } }}上面是将url中的内容转换为本地的html我试了一下,url中需要传递参数的都不成功,不需要传递参数的都可以.我现在有一个jsp的页面,需要转成html,然后保存到数据库里,请问大家有没有什么好的办法. 用不用第三方jar HttpClienthttp://www.ibm.com/developerworks/cn/opensource/os-httpclient/直接给参数就行 空指针问题 对象初始化。 [关于随机数]请大侠们帮小弟看看 救命呀 我要疯了 jxl问题 大虾们 来帮帮小弟吧 如何增加jBuider的虚拟内存 一个未入门的人,求助安装方法(JBuilder)!? 终于找到工作了,爽第一个跟的送100 jar包如何运行呢 命令行提示 无清单属性 怎样得到InputStream的长度? 在POI中,怎么写一个合并的单元格??? PrintWriter 的print没反应 如何用Runtime.getRuntime().exec来打开某个压缩文件,并解压到指定位置? java中读文件的时候能不能忽略空格啊?
import java.net.*;
import java.io.*;
import java.util.*;
public class TestURL {
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:9999/cms/cms/website/test3/index.jsp?siteId=11");
URLConnection urlcon = url.openConnection();
System.out.println("UrlContent TimeOut:"+urlcon.getConnectTimeout());
System.out.println("UrlContent LastModified:"+new Date(urlcon.getLastModified()));
int i = urlcon.getContentLength();
byte[] b=new byte[99999];
System.out.println(i);
File file=new File("d:\\test.html");
FileOutputStream writer=new FileOutputStream(file);
if(i>0){
InputStream is = urlcon.getInputStream();
is.read(b);
writer.write(b);
is.close();
writer.flush();
writer.close();
}else{
System.out.println("Length is null.");
}
}}上面是将url中的内容转换为本地的html我试了一下,url中需要传递参数的都不成功,不需要传递参数的都可以.我现在有一个jsp的页面,需要转成html,然后保存到数据库里,请问大家有没有什么好的办法.
http://www.ibm.com/developerworks/cn/opensource/os-httpclient/
直接给参数就行