我的下面的代码工作正常并从@RequestBody参数
读取xml内容@RequestMapping(method = RequestMethod.POST, value = "{clientCode}/paybycell.xml")
public ModelAndView payByCell(
HttpServletRequest request,
HttpServletResponse response,
@RequestBody String xml,
@PathVariable("clientCode") String clCode,
@RequestParam Integer customerID)
throws InvalidRequestXMLException, InternalException, Exception {
info("request body=="+xml);
getService().validateCityCodeCid(clCode, customerID);
payByCell(xml, clCode, customerID);
response.setStatus(HttpStatus.SC_OK);
return null;
}
日志文件显示内容,例如
request body==<?xml version="1.0"encoding="utf-8" ?>
<PayByCell>
但是我想在不同的方法上使用相同的url模式也请求参数,因此我在@RequestMapping元素中添加了params属性,如下所示
@RequestMapping(method = RequestMethod.POST, value = "/{clientCode}/paybycell.xml", params = { "customerID", "vendorName"})
public ModelAndView payByCellMultipleVendor(
HttpServletRequest request,
HttpServletResponse response,
@RequestBody String xml,
@PathVariable("clientCode") String clCode,
@RequestParam("customerID") Integer customerID,
@RequestParam("vendorName") String vendorName)
throws InvalidRequestXMLException, InternalException, Exception {
if (vendorName == null) {
throw new BadRequestException("Check vendorName");
}
info("request body=="+xml);
getService().validateCityCodeCid(clCode, customerID);
payByCell(xml, clCode, customerID, vendorName);
response.setStatus(HttpStatus.SC_OK);
return null;
}
但现在我的@RequestBody内容未被阅读,并在日志中显示空白,如
request body==
出了什么问题。?
提前感谢任何帮助