解决问题:JSON parse error: error parse new; nested exception is com.alibaba.fastjson.JSONException
fastjson
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
项目地址:https://gitcode.com/gh_mirrors/fastj/fastjson

·
错因:
前后端数据交互时,发现前端数据是以多变量形式传往我后台的,而我后台又是以json格式来接收前端传过来的数据,所以会发现无法接收请求到!
前端传参方式 & 变量传值
而我后端接受方式 @requestBody 以json格式去接收
解决:
既然前端使用& 变量形式传过来的,那我直接干掉@RequestBody注解,不要以json格式来接收即可解决!
@PostMapping("/api/dologin")
@ApiOperation(value = "用户登录", notes = "实现用户登录功能")
public Dto loginUser(@Validated LoginParams loginParams, BindingResult br) {
//jsr 303 验证
if (br.hasErrors()) {
return DtoUtil.getFaild(AlxConstant.ExceptionCode.JSR303CODE, "参数异常");
}
try {
LoginResponse loginResponse = userService.queryItripUser(loginParams);
return DtoUtil.getSuccess(loginResponse);
} catch (LoginExceptions loginException) {
return DtoUtil.getFaild(AlxConstant.ExceptionCode.LOGINERRORCODE, loginException.getMessage());
} catch (Exception e) {
return DtoUtil.getFaild(AlxConstant.ExceptionCode.OHTERCODE, e.getMessage());
}
}




FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
最近提交(Master分支:28 天前 )
c942c834 - 2 年前
5bc4709b - 2 年前
更多推荐
所有评论(0)