3
我有一些控制器(ExampleController
),它接收到content-type
application/x-www-form-urlencoded
的請求。Grails從請求中提取人體數據
我需要使用POST
請求將所有請求數據發送到不同的URL。數據需要與收到的數據相同。
問題是內容不匹配,因爲request.getParameterMap()
破壞了數據的順序。 在ExampleController
:
def method(){
String s = request.reader.text //this is empty, need a way to read this text
Map<String, String[]> vars = request.getParameterMap() //it's not good for me because the map is unordered map
//but it full of data
}
不工作。
我需要這樣的東西:
byte[] data = request.getRequestData()
wr.write(data)
BTW我已經試過:
InputStream = request.getInputStream()
byte [] bytes = inputStream.getBytes()
我也試過
String s = request.reader.text
但字符串是空的。 我認爲主要的問題是grails機制在控制器甚至啓動之前讀取輸入流並將數據放入參數hashMap中。有沒有辦法解決它?
任何幫助,將不勝感激
感謝您的回覆。 request.reader.text是一個空字符串(「」)。所有的數據都在request.parameters HashMap下 – royB