1.get is the data that is fetched from the server, and post is the data sent to the server.
2.get is to add the parameter data queue to the URL that the Action property of the submission form refers to, and the value corresponds to the field one by one in the form, which can be seen in the URL. Post is the httppost mechanism by which the fields within the form are placed within the HTML header with their contents and routed to the URL address referred to by the Action property. The user does not see the process.
3. For Get mode, the server side uses Request.QueryString to get the value of the variable, and for post, the server side uses Request.Form to obtain the submitted data.
4.get transmits a small amount of data and cannot be greater than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, the maximum amount of IIS4 is 100KB in 80KB,IIS5.
5.get Security is very low and post security is high.
Youku: http://v.youku.com/v_show/id_XODU1MzExMjUy.html
Iqiyi Art: Http://www.iqiyi.com/w_19rsechp2t.html#vfrm=8-7-0-1
The following is sent via post data, completed in the client login module, of course, this has to build the server, if there is unfamiliar to the server classmate, can send mail to [email protected], very happy to help everyone, The following is Mainactivity.java, the layout file is no longer given;
public class Mainactivity extends Activity {
Private EditText Ed_name;
Private EditText Ed_password;
Private Button Btn_login;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Ed_name = (EditText) Findviewbyid (r.id.username);
Ed_password = (EditText) Findviewbyid (R.id.upassword);
Btn_login = (Button) Findviewbyid (R.id.btn_login);
Btn_login.setonclicklistener (New Mybuttonlistener ());
}
Class Mybuttonlistener implements onclicklistener{
@Override
public void OnClick (View v) {
String name = Ed_name.gettext (). toString ();
String password = Ed_password.gettext (). toString ();
Postthread pt = new Postthread (name, password);
Pt.start ();
}
}
/* Login successfully put back server characters
* Landing failure will not be put back???
*
*/
Post method sends data to the server
Class Postthread extends thread{
String name;
String password;
Public Postthread (string name, string password) {
Super ();
THIS.name = name;
This.password = password;
}
@Override
public void Run () {
Super.run ();
HttpClient HttpClient = new Defaulthttpclient ();
String url = "Http://192.168.191.1:8080/2.5/LoginServlet";
HttpPost HttpPost = new HttpPost (URL);
A Namevaluepair object that represents a key-value pair that needs to be sent to the server.
Namevaluepair Pair1 = new Basicnamevaluepair ("username", name);
Namevaluepair Pair2 = new Basicnamevaluepair ("Upassword", password);
Wrap it up using the collection class
arraylist<namevaluepair> pairs = new arraylist<namevaluepair> ();
Pairs.add (PAIR1);
Pairs.add (PAIR2);
The request body represents the Request object
try {
Httpentity requestentity = new urlencodedformentity (pairs);
Place the request body in the Request object
Httppost.setentity (requestentity);
HttpResponse response = Httpclient.execute (HttpPost);
if (Response.getstatusline (). Getstatuscode () = = 200) {
httpentity entity = response.getentity ();
BufferedReader reader = new BufferedReader (New InputStreamReader (Entity.getcontent ()));
String Reslut = Reader.readline ();
System.out.println (Reslut);
LOG.D ("HttpPost", "result" +reslut);
}
} catch (Exception e) {
E.printstacktrace ();
}
}
}
}
This article is from the "7851921" blog, please be sure to keep this source http://7861921.blog.51cto.com/7851921/1595032
Android sends data via post to complete client login module