Jquery中使用ajax请求SSM后台时提示:org.springframework.http.converter.HttpMessageNotReadableException: Could no
生活随笔
收集整理的這篇文章主要介紹了
Jquery中使用ajax请求SSM后台时提示:org.springframework.http.converter.HttpMessageNotReadableException: Could no
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
場景
Jquery中使用ajax向SSM后臺請求數據時提示:
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Stream closed
實現
出現這種錯誤是因為前段請求參數和后端接受參數不對應導致。
前端:
?
$.ajax({type: 'POST',url: formAction,cache: false,? //禁用緩存data:JSON.stringify({"guojiStrart":guojiStrart,"guojiEnd":guojiEnd}),contentType: "application/json",dataType: "json",success: function (result) {debugger}});后端錯誤代碼:
@ResponseBody@RequestMapping("/validateIsGuoNeiAll")public Map<String, Object> validateIsGuoNeiAll(@RequestBody Map<String, Object>? param1,@RequestBody Map<String, Object>? param2){Map<String, Object> result = new HashMap<String, Object>();Object PrintId = param1.get("guojiStrart");return result;}正確代碼:
@ResponseBody@RequestMapping("/validateIsGuoNeiAll")public Map<String, Object> validateIsGuoNeiAll(@RequestBody Map<String, Object>? params){Map<String, Object> result = new HashMap<String, Object>();Object PrintId = params.get("guojiStrart");return result;}接受用一個map接收即可。
具體實現案例,參照:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/88717167
?
總結
以上是生活随笔為你收集整理的Jquery中使用ajax请求SSM后台时提示:org.springframework.http.converter.HttpMessageNotReadableException: Could no的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux-用户和组管理以及设置允许远程
- 下一篇: Linux-权限管理相关操作