4.2.3 consumes和produces匹配
//处理request Content-Type为"application/json"类型的请求
@RequestMapping(value="/Content",method=RequestMethod.POST,consumes="application/json")
public String Consumes(@RequestBody Map param){
return "Consumes POST Content-Type=application/json";
}4
上面的示例只允许Content-Type=application/json的HTTP请求映射此方法,其他类型则返回”Unsupported Media Type“的错误。
4.2.4 params和header匹配
1.params
@RequestMapping(value="paramsTest",params="action=save")
public String paramsTest(@RequestBody Map param){
return "params test";
}
2.header
@RequestMapping(value="headerTest",headers={"Host=localhost:8080"})
public String headerTest()
{
return "header test";
}10