recently, the requirement of data interaction between systems has been realized by Http+post method.the usual way isApplication/json Mode direct post JSON objectas
{"siteId":"ZHAN20160329TDLXJND144649","apiSecret":"userid123","workNumber":"FJ-8006-160912-1715-00001","fluetype":"2","apiKey":"yyxt"}
backstage can directly SPRINGMVC directly receive and turn to the related Vo object processing.
in a scenario where the phone interacts with the background, a format requirement is encountered
方法名称:appScanBuildingData
请求:json字符串形式,最外层用data包裹
The demo format example is
data={"alarmDetail":[{"address":"中国","cgi":"CGI0"},{"address":"米国","cgi":"CGI1"},{"address":"日本","cgi":"CGI2"}],"areaCode":"350723","cellNumber":"1599999","cityCode":"350723","lat":"232.545","lon":"98.233","workNO":"ZB33000333337"}
How does this data need to be generated?
The following instructions refer primarily to https://imququ.com/post/four-ways-to-post-data-in-http.html
The format requirements of this wonderful flower are actually usedContent-type: should be for application/x-www-form-urlencoded;the submitted data is encoded in the key1=val1&key2=val2 manner, and both key and Val are URL-transcoded.
POST http://www.example.com HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8
title=test&sub%5B%5D=1&sub%5B%5D=2&sub%5B%5D=3
when transmitting data in Application/json Content-type, the transmitted object simply needs to be serialized by JSON. When the data is transmitted in a application/x-www-form-urlencoded manner. the requested content needs to be: =.. &, .... =.. Format, the content in the
request body will be automatically split with "&" and "=".
application/x-www-form-urlencoded mode transmission, background receive time can use
String data = Request.getparameter ("Data");This is the way to accept data in JSON format. Then use the object as:Alarminfo vo=NULL;Vo=jsonobject. parseobject (Data, Alarminfo. class);
The original intention of this format is to consider the background to receive data conveniently.
From for notes (Wiz)
Web background and phone interactive data format problems