Apache HTTP Client, POST request. How to correctly set request parameters?

后端 未结 3 858
失恋的感觉
失恋的感觉 2021-01-04 12:30

I\'m using Apache HTTP Client and I need to send a POST request to my servlet. When the request is sent my servlet does not receive any parameters (in the HttpServletR

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-04 13:00

    try this:

            List  nvps = new ArrayList ();
            nvps.add(new BasicNameValuePair("IDToken1", "username"));
            nvps.add(new BasicNameValuePair("IDToken2", "password"));
    
            httPost.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));
    

提交回复
热议问题