上海商务网站建设,俄语在线网站建设,查关键词排名,做图书网站的代码我想将txt文件上传到网站,我承认我没有对其进行任何详细的研究,但是我看了一些示例,并希望就我是否朝着正确的方向提出更多的经验性意见. .这是我到目前为止的内容#xff1a;DefaultHttpClient httpClient new DefaultHttpClient();HttpContext localContext new BasicHttp…我想将txt文件上传到网站,我承认我没有对其进行任何详细的研究,但是我看了一些示例,并希望就我是否朝着正确的方向提出更多的经验性意见. .这是我到目前为止的内容DefaultHttpClient httpClient new DefaultHttpClient();HttpContext localContext new BasicHttpContext();private String ret;HttpResponse response null;HttpPost httpPost null;public String postPage(String url,String data,boolean returnAddr) {ret null;httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY,CookiePolicy.RFC_2109);httpPost new HttpPost(url);response null;StringEntity tmp null;try {tmp new StringEntity(data,UTF-8);} catch (UnsupportedEncodingException e) {System.out.println(HTTPHelp : UnsupportedEncodingException : e);}httpPost.setEntity(tmp);try {response httpClient.execute(httpPost,localContext);} catch (ClientProtocolException e) {System.out.println(HTTPHelp : ClientProtocolException : e);} catch (IOException e) {System.out.println(HTTPHelp : IOException : e);}ret response.getStatusLine().toString();return ret;}我称之为postPage(http://www.testwebsite.com,data/data/com.testxmlpost.xml/files/logging.txt,true));我希望能够将文件从设备上传到网站.但是当以这种方式尝试时,我得到以下响应.HTTP/1.1 405 Method Not Allowed我是在尝试正确的方法还是应该以其他方式进行操作