Jas*_*ers 4 java xml servlets httpconnection
我[目前正在使用这样的东西
HttpURLConnection con = (HttpURLConnection) u.openConnection ();
con.setDoInput(true);
con.setRequestMethod("POST");
con.setDoInput (true);
con.setDoOutput (true);
con.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
out = new DataOutputStream(con.getOutputStream());
String content = "username=" + URLEncoder.encode ("bob")
+ "&password=" + URLEncoder.encode ("smith");
System.out.println("\n" + "sending form to HTTP server ...");
out.writeBytes (content);
out.flush ();
out.close ();
con.connect();
Run Code Online (Sandbox Code Playgroud)
有了这个,我设法将一些数据传递给我的服务器.我现在正在徘徊的是这样可以发送多少钱?
我希望能够发送一些xml文件(100~200行),想知道我能不能这样做?
贾森
帖子体(它通常不被称为参数,因为它通常意味着它与URL一起传递)可以是任何长度,仅受配置限制.
由于POST用于实现文件上传,因此大多数系统允许使用相当大的实体.100-200行不应该是一个问题,除了那里最偏执的配置.