我已经查看了该问题的所有其他答案,并尝试了大多数解决方案,但似乎无济于事。我正在使用Dojo.xhrPOST(xhrArgs),它显然在xhrArgs定义之后。

我的xhrArgs:

 xhrArgs =
 {
     headers:
     {
       'Accept': 'application/json',
       'Content-Type': 'application/json'
     },
  'url': thisUrl,
  'postData':requestString,
  'dataType' : 'json',
  'userId': userId,
  'measurementSystem': measurementSystem,
  'systemId': openedSystemId,
  'handleAs': 'text',
  'load': function(data)
     {
         // Replace newlines with nice HTML tags.
         data = data.replace(/\n/g, "<br/>");
         dojo.byId(target).innerHTML = data;
     },
    'error': function(error)
    {
       dojo.byId(target).innerHTML = error;
    }
};


和我的控制器方法签名和注释如下

@RequestMapping(value="/saveSystemConditions", method= RequestMethod.POST,  headers =                                                                               {"content-type=application/json"})
 public String saveSystemConditions(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody Load load, BindingResult result)


和我的requestString如xhrArgs中所示是

"{'systemID':'76', 'system.systemType':'1', 'unitsOfMeasure':'english', 'loadID':'63', 'dispersionInstallationLocation':'Duct+or+AHU', 'humidificationSystemType':'1', 'totalAirVolume':'1200.0', 'desiredDryBulb':'70.0', 'desiredAirMoistureType':'2', 'desiredAirMoisture':'55.0', 'outsideAirConditionsType':'1', 'outsideAirIntakeRateMeasuredAs':'0', 'loadCountry':'United+States', 'outsideAirVolumeMeasuredIn':'0', 'loadState':'Minnesota', 'outsideAirIntakeRate':'25.0', 'loadCity':'Minneapolis', 'elevationFeet':'837.0', 'outsideDryBulb':'-6.8', 'outsideAirMoisture':'57.3', 'userEnteredLoad':'7.43'}"


我懂了
415(不支持的媒体类型)

任何建议将不胜感激。
大卫

最佳答案

Spring MVC映射处理程序以及<mvc:annotation-conig />的显式声明是一个问题。

10-04 18:55