-
GetMethod method = new GetMethod(url); 报错Invalid uri5
Exception in thread "main" java.lang.IllegalArgumentException: Invalid uri 'http://detail.tmall.com/item.htm?spm=a1z10.1.w5003-7662445350.3.PcBVoj&id=38543605541&rn=18b68bfcd2dbadecf752f6983631992d&scene=taobao_shop{**}http://detail.tmall.com/item.htm?spm=a1z10.1.w5003-7662445350.3.PcBVoj&id=38543605541&rn=18b68bfcd2dbadecf752f6983631992d&scene=taobao_shop': Invalid query
at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:222)
at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
报错信息如上,但是同样的程序在Java project 中可以正常运行,在web project中就报出以上错误,程序相同,url的值也是一样的2014年10月10日 16:49
目前还没有答案
相关推荐
GetMethod method = new GetMethod(url); // 执行GET请求 client.executeMethod(method); // 读取服务器返回的响应 String response = method.getResponseBodyAsString(); // 输出响应结果 System.out....
通过http向服务器发出请求,进行数据交互 HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().... GetMethod method = new GetMethod("http://127.0.0.1/config.xml");
GetMethod method = new GetMethod(url); try { // 执行请求 int status = httpclient.executeMethod(method); // 获取响应内容 byte[] responseBody = method.getResponseBody(); // 处理响应数据... ...
GetMethod getMethod = new GetMethod(strURL); // 使用系统提供的默认的恢复策略 getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler()); ...
2. **创建 GetMethod 实例**:然后,创建一个 GetMethod 对象,传入你要访问的 URL。例如,`GetMethod getMethod = new GetMethod("http://www.ibm.com/")`。GetMethod 可以自动处理重定向,如果不想自动跟随重定向...
接着,我们需要创建一个`GetMethod`对象,并设置其URL。这个URL是我们想要访问的网页地址。 ```java GetMethod getMethod = new GetMethod("http://www.ibm.com"); ``` 注意,如果目标URL包含重定向,可以通过`...
GetMethod getMethod = new GetMethod(url); getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler()); try { httpClient.executeMethod(getMethod); ...
GetMethod getMethod = new GetMethod(url); getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler()); try { httpClient.executeMethod(getMethod); ...
GetMethod getMethod = new GetMethod(url); // 设置 get 请求超时为 5 秒 getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 5000); // 设置请求重试处理,用的是默认的重试处理:请求三次 ...
HttpMethod getMethod = new GetMethod("http://www.ibm.com/"); try { httpClient.executeMethod(getMethod); int statusCode = getMethod.getStatusCode(); if (statusCode != HttpStatus.SC_OK) { System....
getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler()); try { int statusCode = httpClient.executeMethod(getMethod); System.out.println(...
GetMethod method = new GetMethod(request); int status = client.executeMethod(method); if (status == HttpStatus.SC_OK) { InputStream input = method.getResponseBodyAsStream(); // 读取输入流 } ``` 4)...
GetMethod getMethod = new GetMethod(url); getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 5000); getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, ...); int status...
一、使用 HttpClient 抓取网页数据 public String getHtml(String htmlurl) throws IOException { StringBuffer sb = new ... GetMethod method = new GetMethod(htmlurl); int statusCode; try { status
GetMethod method = new GetMethod("http://java.sun.com"); int statusCode = client.executeMethod(method); if (statusCode == HttpStatus.SC_OK) { System.out.println("Response status code: " + status...
GetMethod getMethod = new GetMethod("http://example.com"); int statusCode = httpClient.executeMethod(getMethod); if (statusCode == HttpStatus.SC_OK) { InputStream is = getMethod....
getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler()); try { int statusCode = httpClient.executeMethod(getMethod); if (statusCode != ...
GetMethod method = new GetMethod(url); try { client.executeMethod(method); InputStream is = method.getResponseBodyAsStream(); Reader reader = new InputStreamReader(is, "UTF-8"); char[] cbuf = ...
Method method = clazz.getMethod("yourMethodName"); method.invoke(instance); ``` 对于含有Object类型参数的方法,我们需要将参数对象作为`invoke()`方法的第二个参数传入。假设我们有一个接受String参数的方法...