4
我找不出來幾個參數和標題綁定到一個請求參數使用註釋在春季3綁定多個請求參數一個對象在春季3
例如一種方式,讓我們說我越來越這個請求:
Headers:
Content-type: text/plain;
POST Body:
Name: Max
現在,我想這一切神祕地綁定到該對象:
class NameInfo {
String name;
}
使用一些像這樣的代碼:
String getName() {
if ("text/plain".equals(headers.get("content-type"))) {
return body.get("name");
} else if ("xml".equals(headers.get("content-type")) {
return parseXml(body).get("name");
} else ...
}
所以在最後我將能夠使用:
@RequestMapping(method = RequestMethod.POST)
void processName(@RequestAttribute NameInfo name) {
...
}
有沒有辦法實現類似於我所需要的東西嗎?
在此先感謝。