HttpClientを使用して2つのフィールド、IDおよびデータをサーブレットに投稿しようとしています。 問題は、データフィールドの長さが1MB未満であれば、サーブレットは私が投稿したものを取得するということです。しかし、データフィールドの長さが1MBを超える場合、サーブレットはすべてのフィールドに対してnullを受け取ります。私はここで何が欠けていますか?ありがとう。ここhttpclientを使用してサーブレットにデータを投稿しています
私はサーブレットに投稿サンプルデータは次のとおり=ベース64は
符号化されたファイルの内容は、ここで方法
ID = 12312123123123の
データです私がサーブレットにデータを投稿するのに使用します。
private byte[] post(String aUrl, Map<String,String> aParams, String aCharsetEnc, int aMaxWaitMs) throws Exception { PostMethod post = null; try { HttpClient client = new HttpClient(); post = new PostMethod(aUrl); post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=" + aCharsetEnc); for (String key : aParams.keySet()) { post.addParameter(key, aParams.get(key)); } final int code = client.executeMethod(post); if (code == HttpStatus.SC_NO_CONTENT || code == HttpStatus.SC_NOT_FOUND) { return null; } else if (code != HttpStatus.SC_OK) { throw new HttpException("Error code " + code + " encountered."); } InputStream stream = post.getResponseBodyAsStream(); if (stream != null) { return BlobHelper.readBytes(stream); } return null; } finally { if (post != null) { post.releaseConnection(); } } }
サーブレットのメソッドは次のとおりです。
public void doPost(HttpServletRequest aReq, HttpServletResponse aResp) throws ServletException, IOException { setNoCache(aResp); aResp.setContentType("text/plain"); try { final String id = aReq.getParameter(PARAM_ID); final String dataStr = aReq.getParameter(PARAM_DATA); if (log().isDebugEnabled()) { log().debug("id=" + id); log().debug("data=" + dataStr); } } catch (Exception e) { } }