Failed to load resource: the server responsed with a status of 400 (Bad Request)
2016-11-29 21:24
519 查看
ajax请求失败:Failed to load resource: the server responsed with a status of 400 (Bad Request)
一般情况下,造成这个错误的原因有两个: 1. 请求url错误; 2. 前后台数据格式不匹配。
遇到这个问题,首先检查ajax请求url是否正确,前台ajax请求的url与后台配置是否一致
$.ajax({
url: SUBSYSTEM_APP_NAME + "reportsetting/saveReportSetting",
......
});
后台接收请求:
@RequestMapping(value = "saveReportSetting", method = RequestMethod.POST)
如果url配置正确,那么就应该检查前台传递数据格式与后台接收数据的格式是否一致
$.ajax({
url: SUBSYSTEM_APP_NAME + "reportsetting/saveReportSetting",
...
data: JSON.stringify(getAllData()),
...
});
var getAllData = function () {
return {
id: $idHidden.val(),
name: $name.val(),
reportTemplate: {id: $reportTemplate.val()},
active: true,
weeklyGenerationTime: $weeklyGenerationTime.val(),
startTime: $startTime.val(),
endTime: $endTime.val(),
reportStatisticsType: $reportStatisticsType.val(),
fileType: $fileType.val(),
parametersMap: getParameters(),
sender: $sender.val(),
password: $password.val(),
contacts: getContactIds($contactsPeopleTable)
};
};
@RequestMapping(value = "saveReportSetting", method = RequestMethod.POST)
@ResponseBody
public JsonResult saveReportSetting(SessionInfo sessionInfo, @RequestBody ReportSetting reportSetting)
throws IOException
上述代码表示getAllData这个函数返回的数据结构与ReportSetting的数据结构应匹配。当修改某个model类之后,需要检查涉及到的数据结构是否要做相应的更改。
除此之外,当你在某个model类中新加属性之后,要为其添加getter和setter,并且该类必须要有一个default constructor。
一般情况下,造成这个错误的原因有两个: 1. 请求url错误; 2. 前后台数据格式不匹配。
遇到这个问题,首先检查ajax请求url是否正确,前台ajax请求的url与后台配置是否一致
$.ajax({
url: SUBSYSTEM_APP_NAME + "reportsetting/saveReportSetting",
......
});
后台接收请求:
@RequestMapping(value = "saveReportSetting", method = RequestMethod.POST)
如果url配置正确,那么就应该检查前台传递数据格式与后台接收数据的格式是否一致
$.ajax({
url: SUBSYSTEM_APP_NAME + "reportsetting/saveReportSetting",
...
data: JSON.stringify(getAllData()),
...
});
var getAllData = function () {
return {
id: $idHidden.val(),
name: $name.val(),
reportTemplate: {id: $reportTemplate.val()},
active: true,
weeklyGenerationTime: $weeklyGenerationTime.val(),
startTime: $startTime.val(),
endTime: $endTime.val(),
reportStatisticsType: $reportStatisticsType.val(),
fileType: $fileType.val(),
parametersMap: getParameters(),
sender: $sender.val(),
password: $password.val(),
contacts: getContactIds($contactsPeopleTable)
};
};
@RequestMapping(value = "saveReportSetting", method = RequestMethod.POST)
@ResponseBody
public JsonResult saveReportSetting(SessionInfo sessionInfo, @RequestBody ReportSetting reportSetting)
throws IOException
上述代码表示getAllData这个函数返回的数据结构与ReportSetting的数据结构应匹配。当修改某个model类之后,需要检查涉及到的数据结构是否要做相应的更改。
除此之外,当你在某个model类中新加属性之后,要为其添加getter和setter,并且该类必须要有一个default constructor。
相关文章推荐
- ajaxSubmit 报错 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- ajax 报错 400 (Failed to load resource: the server responded with a status of 400 (Bad Request))
- Failed to load resource: the server responded with a status of 400 (Bad Request)
- 关于使用springmvc时Failed to load resource: the server responded with a status of 400 (Bad Request)错误可能原因
- 关于前台jsp页面Failed to load resource: the server responded with a status of 400 (Bad Request)
- 关于使用springmvc时Failed to load resource: the server responded with a status of 400 (Bad Request)错误可能原因
- 上传文件失败 Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
- Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
- Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
- Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
- jquery:Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to load resource: the server responded with a status of 500 (Internal Server Error)
- Failed to load resource: the server responded with a status of 406 (Not Acceptable)问题的解决方案
- failed to load resource the server responded with a status of 500 (internal server error)
- Failed to load resource: the server responded with a status of 404
- SharePoint Debug - Failed to load resource: the server responded with a status of 500
- Failed to load resource: the server responded with a status of 406 (Not Acceptable)