HttpClient client =NewHttpClient (); String URL= http://Localhost:8080/ana/workflowoainterface.do?action=oatask;Postmethod Postmethod =Newpostmethod (URL);//Set parameter encoding to GBKPost.getparams (). Setparameter (Httpmethodparams.http_content_charset, "GBK");//constructing key-value pair parametersnamevaluepair[] data = {NewNamevaluepair ("Processinstanceid", "230"),NewNamevaluepair ("Approveflag", "1") }; //put the parameter values into the Postmethodpostmethod.setrequestbody (data);//Execution
Client.executemethod (Postmethod);//Get Execution Result code
//Read Content byte[] Responsebody =Postmethod.getresponsebody (); //Working with ContentSystem.out.println (NewString (responsebody)); System.out.println ("Getstatusline:" +postmethod.getstatusline ()); System.out.println ("~~~"+postmethod.getresponsebodyasstring ()); System.out.println ("StatusCode:" +StatusCode); //Print results pageString response =NewString (Postmethod.getresponsebodyasstring (). GetBytes ("Utf-8")); //Print the returned informationSYSTEM.OUT.PRINTLN ("Response:" +response);//Release ConnectionPostmethod.releaseconnection ();If the Chinese parameter is passed, it is possible to get garbled and resolve it by setting the correct parameter encoding. In the called interface side, directly through the request.getparameter way to obtain. Original: http://blog.sina.com.cn/s/blog_49cc672f0100x7sh.html
HttpClient Use Example