在Java中,可以使用各种库来获取FormData数据。以下是一些常用的方法:
String username = request.getParameter("username");
String password = request.getParameter("password");
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("http://example.com");
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("username", "admin"));
params.add(new BasicNameValuePair("password", "123456"));
httpPost.setEntity(new UrlEncodedFormEntity(params));
CloseableHttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
String responseString = EntityUtils.toString(entity);
这些是获取FormData数据的一些常用方法,你可以根据自己的需求选择合适的方法来使用。