首页 前端知识 com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regula

com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regula

2024-05-30 10:05:47 前端知识 前端哥 960 348 我要收藏

报错信息:

Error while extracting response for type [class java.lang.Object] and content type [application/json];

nested exception is org.springframework.http.converter.HttpMessageNotReadableException:

        JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens;

nested exception is com.fasterxml.jackson.core.JsonParseException:

        Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens

JSON的解析异常报错:

我的代码里面的某个字段存入json格式的数据 

{"subtableRights":[{"name":"测试权限","alias":"testPermission","type":"all","setting":""}],"tabBtn":{},"tabList":{null:{"edit_name":"所有人","children":[{"edit_name":"所有人","edit":"everyone","name":"页面1"}],"edit":"everyone","name":"表单TAB"}},"sub":{"testPermission":{"subTabBtn":{"add":{"edit_name":"所有人","edit":"everyone","name":"添加","alias":"add","type":"default","openType":"inner"},"edit":{"edit_name":"所有人","edit":"everyone","name":"编辑","alias":"edit","type":"default","openType":"inner"},"editExist":{"edit_name":"所有人","edit":"everyone","name":"编辑已添加","alias":"editExist","type":"default"},"removeExist":{"edit_name":"所有人","edit":"everyone","name":"删除已添加","alias":"removeExist","type":"default"},"up":{"edit_name":"所有人","edit":"everyone","name":"上移","alias":"up","type":"default","openType":"inner"},"down":{"edit_name":"所有人","edit":"everyone","name":"下移","alias":"down","type":"default","openType":"inner"},"remove":{"edit_name":"所有人","edit":"everyone","name":"删除","alias":"remove","type":"default","openType":"inner"}},"subAttr":{"xh":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"行号","alias":"xh","require":"none","read_name":"所有人"},"lm":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"料名","alias":"lm","require":"none","read_name":"所有人"},"pc":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"批次","alias":"pc","require":"none","read_name":"所有人"},"dw":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"单位","alias":"dw","require":"none","read_name":"所有人"},"hgsl":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"合格数量","alias":"hgsl","require":"none","read_name":"所有人"},"sl":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"数量","alias":"sl","require":"none","read_name":"所有人"},"scrq":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"生产日期","alias":"scrq","require":"none","read_name":"所有人"},"lh":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"料号","alias":"lh","require":"none","read_name":"所有人"},"hw":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","name":"货位","alias":"hw","require":"none","read_name":"所有人"}}}},"main":{"CD":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-textbox","name":"CD","alias":"CD","require":"none","read_name":"所有人"},"B":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-button-edit","name":"B","alias":"B","require":"none","read_name":"所有人"},"s":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-textbox","name":"撒","alias":"s","require":"none","read_name":"所有人"},"DH":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-form-select","name":"DH","alias":"DH","require":"none","read_name":"所有人"},"zxr":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-user","name":"执行人","alias":"zxr","require":"none","read_name":"所有人"},"bz":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-textbox","name":"备注","alias":"bz","require":"none","read_name":"所有人"},"zxsj":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-date","name":"执行时间","alias":"zxsj","require":"none","read_name":"所有人"},"VC":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-textbox","name":"VC","alias":"VC","require":"none","read_name":"所有人"},"rq":{"edit_name":"所有人","read":"everyone","require_name":"无权限","edit":"everyone","dataType":"rx-date","name":"日期","alias":"rq","require":"none","read_name":"所有人"}}}

当时我试着把json格式分成两部分

分别使用Feign接口调用服务间方法时都能调用 合在一起时就出现标题错误感觉奇怪

后续百度之后发现可能是由于JSON长度太大了 默认Feign的调用长度在2048 所以出现这个问题

解决办法:

1.在applucation.yml中增加配置:

feign:
  compression:
    request:
      min-request-size: 30000

注意的是 倘若nacos的配置中也存在这个配置的话 在application.yml中配置就被nacos的配置顶掉了(笔者就是犯了这个错误.......) 默认配置优先级是nacos配置>本机配置 特此贴图告示一下:

转载请注明出处或者链接地址:https://www.qianduange.cn//article/10063.html
标签
评论
发布的文章

用点jquery实现的登录页面

2024-06-06 00:06:07

echarts-锥型柱状图

2024-06-06 00:06:05

echarts的使用

2024-06-06 00:06:00

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!