/*** Post Request Method ** @ param username * @ param password * @ return null indicates that the obtained path is incorrect, text returns the requested data */public static String postRequest (String username, String password) {try {String path = "http: // 172.22.64.156: 8080/0001 AndroidWebService/LoginServlet "; URL url = new URL (path); HttpURLConnection conn = (HttpURLConnection) url. openConnection (); conn. setreadtimeouts (500); conn. setRequestMethod ("POST"); // username = donghongyu & password = 123 // prepare the data to be transmitted String data = "username =" + URLEncoder. encode (username) + "& password =" + URLEncoder. encode (password); // set the type of the request content conn. setRequestProperty ("Content-Type", "application/x-www-form-urlencoded"); conn. setRequestProperty ("Content-Length", data. length () + ""); // enable the conn permission to write data to the server. setDefaultUseCaches (true); // gets the output stream OutputStream OS = conn of the http connection. getOutputStream (); // write data to the Server OS. write (data. getBytes (); int code = conn. getResponseCode (); if (code = 200) {// The request is successful. InputStream is = conn. getInputStream (); String text = StreamUtil. readStream (is); return text;} else {// return null for request failure;} catch (Exception e) {e. printStackTrace ();} return null ;}