Used in the project, need to use httpclient to simulate form transfer form form requirements, in ordinary projects, probably is to send JSON string style requirements, but how to send a form form to the corresponding server?
This requires the namevaluepair of the method, you can do form form data transmission, I recorded here
1. You need to define a collection of Namevaluepair, the elements of this set that are placed in our form form
New Arraylist<>();
Put our form element Pair.add (new basicnamevaluepair ("Licenseno", Licenseno)); Pair.add (new Basicnamevaluepair ("token", token)); Pair.add (new basicnamevaluepair ("City"); Pair.add (new basicnamevaluepair ("timestamp", timestamp)); Pair.add (new basicnamevaluepair ("sign", sign));
2. Use HttpClient in setentity (new urlencodedformentity (pair, HTTP. utf_8)) data transfer is OK.
Use HttpClient to create a request with a cookie and transfer form form