9 Android Client get 登录方式

来源:互联网 发布:高级有限元分析软件 编辑:程序博客网 时间:2024/05/20 10:56
/** client get 登录方式 * 采用HttpClient get 提交数据 * @param usename * @param password * @return 返回null 登录异常 * @throws Exception */public static String loginByClientGet(String usename,String password){try{//1. 打开一个浏览器HttpClient clien=new DefaultHttpClient();//2、 输入地址String path="http://192.1.100::8080/web/LoginServlet?username="+URLEncoder.encode(usename)+"&password"+URLEncoder.encode(password);HttpGet httpGet=new HttpGet(path);//3.敲回车HttpResponse response=clien.execute(httpGet);int code=response.getStatusLine().getStatusCode();if(code==200){InputStream is=response.getEntity().getContent();//String text=StreamTools.readInputStrams(is);return ""+"text";}else{return null;} } catch(Exception e) {  e.printStackTrace(); }}}

0 0
原创粉丝点击