Use HttpClient to create a request with a cookie and transfer form form

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.