手机微博的回收站回收站在哪里

HTTPPost发送JSON:
private static final String APPLICATION_JSON = &application/json&;
private static final String CONTENT_TYPE_TEXT_JSON = &text/json&;
public static void httpPostWithJSON(String url, String json) throws Exception {
// 将JSON进行UTF-8编码,以便传输中文
String encoderJson = URLEncoder.encode(json, HTTP.UTF_8);
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);
StringEntity se = new StringEntity(encoderJson);
se.setContentType(CONTENT_TYPE_TEXT_JSON);
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON));
httpPost.setEntity(se);
httpClient.execute(httpPost);
接收HTTPPost中的JSON:
public static String receivePost(HttpServletRequest request) throws IOException, UnsupportedEncodingException {
// 读取请求内容
BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
String line =
StringBuilder sb = new StringBuilder();
while((line = br.readLine())!=null){
sb.append(line);
// 将资料解码
String reqBody = sb.toString();
return URLDecoder.decode(reqBody, HTTP.UTF_8);
以上摘自:/blog/1954128
以下为自己开发实例:
接收HTTPPost中的JSON:
&pre name=&code& class=&java& style=&font-size: 13 line-height: 19&&import com.google.gson.G &
public AttendanceInfo getAttendanceInfoFromBbchat(){
// 读取请求内容
ToftContext context = ToftContext.getToftContext();
InputStream in = context.getRequest().getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
StringBuffer stringBuffer = new StringBuffer();
String str = &&;
while ((str = br.readLine()) != null) {
stringBuffer.append(str);
String info = stringBuffer.toString();
if(StringUtils.isNotBlank(info)){
Gson gson = new Gson();
AttendanceInfo attendanceInfo = gson.fromJson(info, AttendanceInfo.class);
if(StringUtils.isNotBlank(attendanceInfo.getToken())){
context.getRequest().setAttribute(&token&, attendanceInfo.getToken());
return attendanceI
}catch (Exception e) {
// TODO: handle exception
log.error(&bbchat 解析邦邦社区考勤json参数出现异常&);
e.printStackTrace();
HTTPPost发送JSON:
public static String pushAttendanceInfo(){
String url = &:8080/push/push&;
HttpClient httpClient = new HttpClient();
// 设置连接超时时间(单位毫秒)
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(60*1000);
// 设置读取超时时间(单位毫秒)
httpClient.getHttpConnectionManager().getParams().setSoTimeout(60*1000);
PostMethod method = new PostMethod(url);
String info =
String aaa = &{\&token\&: \&ee32daaf2ba\&,\&touser\&:\&AB044979\&&+
&,\&msgtype\&:\&text\&,\&msg\&:{\&content\&: \&Hello\&},\&start\&:\&\&,\&end\&:\& 00:00:00\&}&;
RequestEntity entity = new StringRequestEntity(aaa, &application/json&, &UTF-8&);
method.setRequestEntity(entity);
httpClient.executeMethod(method);
int code = method.getStatusCode();
if (code == HttpStatus.SC_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
StringBuffer stringBuffer = new StringBuffer();
String str = &&;
while ((str = reader.readLine()) != null) {
stringBuffer.append(str);
info = stringBuffer.toString();
(&bbchat 返回报文:&+info);
log.error(&bbchat 接口返回失败
httpStatusCode=&+code);
} catch (Exception ex) {
ToftLogger.error(&内部接口报文发送异常:& + ex.getMessage());
ex.printStackTrace();
} finally {
if (method != null) {
method.releaseConnection();
HTTPPost发送参数:
* 考勤推送接口登陆
public static String loginAttendancePush(){
String url = &:8080/authenticate/ablogin&;
HttpClient httpClient = new HttpClient();
// 设置连接超时时间(单位毫秒)
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(60*1000);
// 设置读取超时时间(单位毫秒)
httpClient.getHttpConnectionManager().getParams().setSoTimeout(60*1000);
PostMethod method = new PostMethod(url);
String info =
method.setParameter(&username&, &27607&);
method.setParameter(&password&, &cd55abee1c0ef6dfaf00c96aceb39b9&);
httpClient.executeMethod(method);
int code = method.getStatusCode();
if (code == HttpStatus.SC_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
StringBuffer stringBuffer = new StringBuffer();
String str = &&;
while ((str = reader.readLine()) != null) {
stringBuffer.append(str);
info = stringBuffer.toString();
(&bbchat 返回报文:&+info);
log.error(&bbchat 接口返回失败
httpStatusCode=&+code);
} catch (Exception ex) {
ToftLogger.error(&内部接口报文发送异常:& + ex.getMessage());
ex.printStackTrace();
} finally {
if (method != null) {
method.releaseConnection();jquery中$.post()方法的简单实例
字体:[ ] 类型:转载 时间:
本篇文章主要是对jquery中$.post()方法的简单实例进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助
在jqery中有这样一个方法,$.post()下面就这个方法做一个简单的实例:
jQuery.post( url, [data], [callback], [type] ) :使用POST方式来进行异步请求
url (String) : 发送请求的URL地址.
data (Map) : (可选) 要发送给服务器的数据,以 Key/value 的键值对形式表示。
callback (Function) : (可选) 载入成功时回调函数(只有当Response的返回状态是success才是调用该方法)。
type (String) : (可选)官方的说明是:Type of data to be sent。其实应该为客户端请求的类型(JSON,XML,等等)
1.html页面(index.html) 代码如下:&!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&&html xmlns="http://www.w3.org/1999/xhtml"&&head&&meta http-equiv="Content-Type" content="text/ charset=gb2312" /&&title&Untitled Document&/title&&script type="text/javascript" src=\'#\'" /jquery-1.3.2.js"&&/script&&script language="javascript"&function checkemail(){& if($('#email').val() == ""){&&& $('#msg').html("please enter the email!");&&& $('#email').&&&& }& if($('#address').val() == ""){&&& $('#msg').html("please enter the address!");&&& $('#address').&&&& }& ajax_post();}
function ajax_post(){& $.post("action.php",{email:$('#email').val(),address:$('#address').val()},& function(data){&&& //$('#msg').html("please enter the email!");&&& //alert(data);&&& $('#msg').html(data);& },& "text");//这里返回的类型有:json,html,xml,text}&/script&&/head&
&body&&form id="ajaxform" name="ajaxform" method="post" action="action.php"&&&& &p&&&& email&input type="text" name="email" id="email"/&&&& &/p&&&& &p&&&& address&input type="text" name="address" id="address"/&&&& &/p&&&& &p id="msg"&&/p&&&& &p&&&& &&&&&&& &input name="Submit" type="button" value="submit" onclick="return checkemail()"/&&&& &/p&&/form&&/body&&/html&2.php页面(action.php) 代码如下:&?php$email = $_POST["email"];$address = $_POST["address"];
//echo $//echo $echo "success";?&说明:当点击按钮时,注意按钮现在的类型是button.在不使用$.post()方法时,按钮类型是submit,这样submit提交form里的数据,采用post方法传递到页面action.php,这时在页面action.php中就能接受到传过来的数据。当采用$.post方法时,我们在函数ajax_post()方法中其实就是使用了post的方法。(要引用jquery库文件)
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具相关文章推荐:
WebView post请求
原本以前API接口都是通过GET去获取数据,因为没有要求验证信息,所有把带的参数等信息都可以直接在URL看到,最近要求数据提交采用post方式,在把原本SHELL通过GET的接口转为post的情况中了解了一些资料。
一、GET和post的区别
post相比与GET来说是相对安全,所谓的相对安全其实post和GET都是明文传输的,通过抓包还是能看到里面的数据。相对安全是GET只要通过URL就可以看到传输的信息,而post里面参数数据是存放...
网络与安全
阅读(2370) 回复(0)
其他文章推荐
表单提交中GET 和post 方式的区别主要有以下5点:
(1).GTE 用于向服务器请求请求,post 用于向服务器传送数据
(2).GET 把参数数据队列加到提交表单的ACTION属性所指的url,值和字段一一对应,url可以看到;post通过HTTPpost机制,将表单内各字段和内容放在HTML的HEADER内一起传送给ACTION属性所指的url中,用户看不到这个过程。
(3).对于GET 方式,服务器用request.querystring 获取变量的值,对于post方式,服务器用request.form ...
阅读(30) 回复(0)
用Java写数据到post请求
HTTP post请求最常见的用途是发送表单参数到服务器。除了发送表单数据,还可以使用post的消息Body体发送各种数据(如纯文本、XML文档等)。本文讲述如何用Java将数据写入post请求的Body体。
[java] view plaincopyprint?
import java.io.IOE
import java.io.InputS
import java.io.OutputStreamW
阅读(60) 回复(1)
使用php curl模拟post请求的小例子,提供大家学习一下
$uri = &/test.php&;//这里换成你服务器的地址
// 参数数组
$data = array (
'name' =& 'tanteng'
// 'password' =& 'password'
$ch = curl_init ();
// print_r($ch);
curl_setopt ( $ch, CURLOPT_URL, $uri );
curl_setopt ( $ch, CURLOPT_post, 1 );
curl_setopt ( $ch, CURLOP...
阅读(0) 回复(0)
转自:http://www.blogjava.net/Green-nut/articles/346789.html
package com.
import java.io.BufferedR
import java.io.IOE
import java.io.InputStreamR
import java.util.L
import org.apache.http.HttpE
import org.apache.http.HttpR
import org.apache.http.client.ClientProtocolE
import org.apache.http.client.methods.Httppost;
import org.apache...
阅读(180) 回复(0)
首先我用的httpclient4.3.1,用gradle管理的项目,先上gradle引入的包
apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
mavenCentral()
dependencies {
// httpclient
compile 'org.apache.httpcomponents:httpclient:4.3.1'
阅读(360) 回复(0)
类似于dreamhost这类主机服务商,是显示fopen的使用的。使用php的curl可以实现支持FTP、FTPS、HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE和LDAP。curl 支持SSL证书、HTTP post、HTTP PUT 、FTP 上传,kerberos、基于HTT格式的上传、代理、cookie、用户+口令证明、文件传送恢复、http代理通道就最常用的来说,是基于http的 get和post方法。
代码实现:
1、http的get实现
阅读(0) 回复(0)
利用httplib 以http发送post请求网上很多资料。https的处理方式,有所不同,弄不好,报480等错误。
正确的处理方式,上代码:
#HTTPS发送post请求范例
import httplib
import ssl
import socket
import base64
import simplejson
receipt = '{&data&:1111}'
encodedReceipt = base64.b64encode(receipt)
Python/Ruby
阅读(360) 回复(0)
/*缩放页面方式1.
websetting.setInitialScale(55);
/*缩放页面方式2. 会出现放大缩小的按钮
websetting.setSupportZoom(true);
websetting.setBuiltInZoomControls(true);
/*缩小页面方式3.
websetting.setDefaultZoom(WebSettings.ZoomDensity.FAR);
Android平台
阅读(30) 回复(0)
哦,亲爱的明信片,你准时抵达,像平常相同,你抵达适宜的时刻,当我躺在这儿死去。我猜它是用一个信封的信,从那天他问我地址。当我在吃早饭抵达喂养机。白叟说:这儿是你的一封信,你等待已久的信。
我是说,白叟的小妹和我不会感到惊奇,在她面前或折叠到白鸽喂养机。所以,如同它是全部休闲,我放置了明信片,像一片树叶的糖果一边独自吸时,有一自个都没有。我来到房间,这样的安静,渐渐就如同啥都没发生过,数着...
阅读(0) 回复(0)
//wView.loadUrl(&file:///android_asset/index.html&);
-----打开本包内asset目录下的index.html文件
//wView.loadUrl(&content://com.android.htmlfileprovider/sdcard/index.html&);
-----打开本地sd卡内的index.html文件
//wView.loadUrl(&&);
-----打开指定URL的html文件
Android平台
阅读(0) 回复(0)
盛拓传媒:
北京皓辰网域网络信息技术有限公司. 版权所有
北京市公安局海淀分局网监中心备案编号:
广播电视节目制作经营许可证:编号(京)字第1149号
ITPUB推荐文章解答你所有技术难题Javascript使用post方法提交数据实例
Javascript使用post方法提交数据实例
本文实例讲述了Javascript使用post方法提交数据的方法。分享给大家供大家参考。具体如下:
使用JS提交数据时,可以调用本方法实现post方式的提交。
var jsPost = function(action, values) {
var id = Math.random();
document.write('&form id="post' + id + '" name="post'+ id +'" action="' + action + '" method="post"&');
for (var key in values) {
document.write('&input type="hidden" name="' + key + '" value="' + values[key] + '" /&');
document.write('&/form&');
document.getElementById('post' + id).submit();
jsPost('b.html', {
'username': 'zhangsan',
'password': '123'
希望本文所述对大家的javascript程序设计有所帮助。
Copyright & 2016 phpStudy

我要回帖

更多关于 手机微博的回收站 的文章

 

随机推荐