首页 新闻 会员 周边

文本框打了回车键,JSON转换失败

0
悬赏园豆:10 [已解决问题] 解决于 2022-01-07 17:13

如题,在一个文本框里面输入内容时,打了回车键,结果JSON转换失败。
有什么解决方案么?
就算是配置了JSON格式化:
FastJsonConfig.setSerializerFeatures( SerializerFeature.PrettyFormat );
也只是可以让springboot接收到参数,但是转换时,会产生异常。

Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Illegal unquoted character ((CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value<LF> at [Source: (PushbackInputStream); line: 6, column: 17] (through reference chain: com.ymy.wechat.callBackManagement.param.input.HospitalCGParam["why"])]
2022-01-07 16:17:15.369 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Completed 400 BAD_REQUEST
2022-01-07 16:17:15.369 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - "ERROR" dispatch for POST "/ymy/error", parameters={}
2022-01-07 16:17:15.369 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
2022-01-07 16:17:15.370 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.m.annotation.HttpEntityMethodProcessor - Using 'application/json', given [/] and supported [application/json, application/+json, application/json, application/+json]
2022-01-07 16:17:15.370 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.m.annotation.HttpEntityMethodProcessor - Writing [{timestamp=Fri Jan 07 16:17:15 CST 2022, status=400, error=Bad Request, path=/ymy/sp/hospitalCGAppro (truncated)...]
2022-01-07 16:17:15.371 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet - Exiting from "ERROR" dispatch, status 400

明日小路的主页 明日小路 | 菜鸟二级 | 园豆:466
提问于:2022-01-07 16:21
< >
分享
最佳答案
0

你可以转换前,先格式化去掉特殊字符,搜索下百度就有

收获园豆:10
RolyPoly_Toy | 菜鸟二级 |园豆:217 | 2022-01-07 17:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册