android与jsp http post方式通信
来源:互联网 发布:数据处理软件pen 编辑:程序博客网 时间:2024/04/30 23:01
android端
public void ppost() { String uriAPI = "http://xx.xxxx.xx:17777/Nafio/Emulator/test/tempPostWml.jsp";/*建立HTTP Post连线*/ HttpPost httpRequest =new HttpPost(uriAPI); //Post运作传送变数必须用NameValuePair[]阵列储存 //传参数 服务端获取的方法为request.getParameter("name") List <NameValuePair> params=new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("imei","imei"));params.add(new BasicNameValuePair("wml","我的测试")); try{ //发出HTTP requesthttpRequest.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));//注意这里要写成utf-8,与jsp对应//取得HTTP responseHttpResponse httpResponse=new DefaultHttpClient().execute(httpRequest); //若状态码为200 okif(httpResponse.getStatusLine().getStatusCode()==200){ //取出回应字串 String strResult=EntityUtils.toString(httpResponse.getEntity());}else{ Log.e("n", "b");} }catch(ClientProtocolException e){ e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
服务端jsp
<%@ page language="java" contentType="text/html; charset=gb2312"%><%@ page import="temp.TempRecordWml" %> <!--request.setCharacterEncoding("utf-8"); --><%String imei = new String(request.getParameter("imei").getBytes("ISO-8859-1"),"utf-8");String wml = new String(request.getParameter("wml").getBytes("ISO-8859-1"),"utf-8");TempRecordWml t=new TempRecordWml();String str = t.createConfigFile(imei,wml);out.println("中文");response.getWriter().write("imei->"+imei+" "+"wml->"+wml);%>
- android与jsp http post方式通信
- android使用Http的Post方式与网络交互通信
- HTTP通信POST方式
- Android之Http通信GET与POST
- Android程序:使用Http的Post方式与网络交互通信
- JAVA:使用 HTTP 的 Post 方式与网络交互通信
- 使用http的post方式与网络交互通信
- Http与网络通信(GET和POST方式)
- java33.HTTP通信------使用Http的Post方式与网络交互通信
- android利用post方式与web服务器通信
- Android中基于HTTP的通信技术(4)使用HttpClient进行Post方式通信
- java35.HTTP通信------使用HttpClient进行Post方式通信
- iOS项目开发实战——通过Http Post方式与服务器通信
- HttpClient-----2、使用HTTP的POST方式与网络交互通信
- android中的http通信---(3)通过get、post方式传数据给服务器
- IOS 通过POST方式与服务器通信
- Android中基于HTTP的通信技术(2)使用Http的Post方式读取网络数据
- HTTP请求方式:get与post
- 跨平台移动开发实战(十二)------HTML5安全
- SurfaceView与多线程
- 让Myeclipse支持jQuery、Ext等主流框架自动完成、调试功能,Myeclipse集成Apatana
- HDU 2642 二维树状数组问题
- Linux命令之pwd
- android与jsp http post方式通信
- SQL SERVER错误代码大全
- IFrame高度设置
- SEO优化(增加搜索爬虫)
- 备份恢复IBM DB2数据库的基本步骤-----文件转自DB2china
- QT国际化机制的相互矛盾的地方[Q_PROPERTY与tr函数]
- 鼠标放到控件上 DIV悬浮提示效果(四种)
- C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- ClipboardService(CBS)中的权限管理