我已经查看了这个问题的所有其他答案并尝试了大多数解决方案,但似乎没有任何效果。我正在使用 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(不支持的媒体类型)
任何建议将不胜感激。大卫