For some reason, you need to simulate Http post and submit data to the server. I have learned many ways, such as ajax simulation and injection. I think it's too advanced and I don't know much about it. So I thought about it. I am also a java programmer, find a java app. Therefore, the baidu and google methods were used to directly find an out-of-the-box simulation method. I made a simple modification. The Code is as follows:
1 public class HttpPostSimulator {2 public static void post () throws IOException {3 4 URL = new url ("http://a. B .com/dda/updateCCC.action"); 5 URLConnection connection = URL. openConnection (); 6 connection. setDoOutput (true); 7 OutputStreamWriter out = new OutputStreamWriter (8 connection. getOutputStream (), "UTF-8"); 9 10 // post Data 11 out. write ("s. code = de0947 & s. typeCode = ccc "); 12 // pass data to the page. The key to post! 13 out. flush (); 14 out. close (); 15 16 // once the message is sent successfully, use the following method to get the server response: 17 String sCurrentLine; 18 String sTotalString; 19 sCurrentLine = ""; 20 sTotalString = ""; 21 // The legendary Three-tier package! 22 BufferedReader resultReader = new BufferedReader (new InputStreamReader (23 connection. getInputStream (); 24 while (sCurrentLine = resultReader. readLine ())! = Null) {25 sTotalString + = sCurrentLine + "\ r \ n"; 26 27} 28 System. out. println (sTotalString); 29 30} 31 32 public static void main (String [] args) throws IOException {33 post (); 34} 35}
Reference address:
Simulate Post submission form data using Java
Http://blog.csdn.net/kalision/article/details/7920908