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) {
...
}
有没有办法实现类似于我所需要的东西吗?
在此先感谢。