2
我使用郵遞員客戶端發送RES請求,這個不安分的路由器:的Restlet後getFirstValue總是返回null
public Representation createAgent(Representation entity) {
Form form = new Form(entity);
String user = form.getFirstValue("user");
String password = form.getFirstValue("password");
System.out.println("user: "+ user);
System.out.println("password: "+ password);
System.out.println("form: "+ form.toString());
return (agent.save(getUser(),getPassword()))
? new StringRepresentation("user "+ user +" created", MediaType.TEXT_PLAIN)
: new StringRepresentation("agent creation failed",MediaType.TEXT_PLAIN);
}
UserA和密碼總是空雖然打印form.toString()顯示:
[[------WebKitFormBoundaryb4FkGv8CgddIf8rn
Content-Disposition: form-data; name="user"
ali
------WebKitFormBoundaryb4FkGv8CgddIf8rn
Content-Disposition: form-data; name="password"
dsndfjo32
------WebKitFormBoundaryb4FkGv8CgddIf8rn--
]]
下面是在預覽模式下的全郵遞員要求:
POST /v1/agents HTTP/1.1
Host: localhost:9000
Authorization: Basic c2NvdHQ6amRmZ2pkZnRnaA==
Cache-Control: no-cache
Postman-Token: ef58fda2-8974-0d9f-7a23-10c94df8552e
Content-Type: multipart/form-data; boundary=---- WebKitFormBoundary7MA4YWxkTrZu0gW
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="user"
ali
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="password"
dsndfjo32
----WebKitFormBoundary7MA4YWxkTrZu0gW