小编vin*_*tty的帖子

在放心的情况下,如何设置url编码的表单实体并向表单实体添加参数?

下面的示例代码在http客户端中,但是我想在Rest Assured中编写相同的代码。我知道我们也可以放心使用http库,但是我想放心使用

HttpPost pst = new HttpPost(baseUrl, "j_spring_security_check"))
pst.setHeader("Content-Type", "application/x-www-form-urlencoded")
ArrayList<NameValuePair> postParam = new ArrayList<NameValuePair>()
postParam .add(new BasicNameValuePair("j_username",username))
postParam .add(new BasicNameValuePair("j_password",password))
UrlEncodedFormEntity formEntity23 = new UrlEncodedFormEntity(postParam)
pst.setEntity(formEntity23 )
HttpResponse response = httpclient.execute(pst);
Run Code Online (Sandbox Code Playgroud)

api rest rest-assured apache-httpclient-4.x

3
推荐指数
1
解决办法
4272
查看次数

标签 统计

apache-httpclient-4.x ×1

api ×1

rest ×1

rest-assured ×1