2012-05-15 67 views
1
我使用

POST請求代碼:如何通過陣列在HTTPBuilder POST請求

def http = new HTTPBuilder(uri) 
http.request(Method.POST, ContentType.TEXT){ 
    send ContentType.URLENC, attrs 

    ..Response handler code...   
} 

這裏ATTRS是關鍵&值的地圖需要傳遞,如:

[param1:'value1', param2:'value2', param3:'value3] 

我需要支持傳遞相同參數的多個值,因此作爲地圖傳遞不是一個選項。在這種情況下,我的選擇是什麼?我需要傳遞:

[param1:'value1', param1:'value2', param3:'value3'] 

回答

2

你應該能夠做到:

send URLENC, [param1:['value1','value2'], param3:'value3'] 

您的例子也不會映射工作,不能有多個按鍵名稱相同