Feign 调用出现的net.sf.json.exception:Unquotted String错误,解决办法。
来源:互联网 发布:mysql 5.1.65.tar.gz 编辑:程序博客网 时间:2024/05/16 08:43
错误原因:
/***请求*/@ResponseBody @RequestMapping(value = "/queryMobileChainClinicCount.do", method = RequestMethod.POST) public Object queryMobileChainClinicCount(String clinicID, String openID) { logger.begin(); logger.debug("queryMobileChainClinicCount Parameters", clinicID); ResultMessage message = new ResultMessage(); try { Map<String, String> parameterMap = new HashMap<String, String>(); parameterMap.put("clinicID", clinicID); parameterMap.put("openID", openID); Integer count = mobileLoginService.queryMobileChainClinicCount(parameterMap);//feign 服务接口 message.setCode(CodeConstant.SUCCESS); message.setData(count); logger.debug("message", message); } catch (BusinessException e) { message.setCode(e.getErrorCode()); message.setCodeDesc(e.getErrorDes()); logger.error(e); } catch (Exception e) { message.setCode(CodeConstant.SYSTEM_ERROR); message.setCodeDesc(ResourceUtils.getResultCodeDesc(CodeConstant.SYSTEM_ERROR)); logger.error(e); } logger.end(); return message; }
原因是使用hashMap,在传输过程中hashMap的toString方法不会添加引号,于是在接收参数做json转换出现了如上问题,解决方法将HashMap替换成JSONObject
HashMap toString
public String toString() { Iterator<Entry<K,V>> i = entrySet().iterator(); if (! i.hasNext()) return "{}"; StringBuilder sb = new StringBuilder(); sb.append('{'); for (;;) { Entry<K,V> e = i.next(); K key = e.getKey(); V value = e.getValue(); sb.append(key == this ? "(this Map)" : key); sb.append('='); sb.append(value == this ? "(this Map)" : value); if (! i.hasNext()) return sb.append('}').toString(); sb.append(',').append(' '); } }
阅读全文
0 0
- Feign 调用出现的net.sf.json.exception:Unquotted String错误,解决办法。
- net.sf.json.exception:Unquotted String错误,解决办法。
- Exception in thread "main" net.sf.json.JSONException: Unquotted string
- net.sf.json.JSONException: Unquotted string "E44C2B0168A550F6503F59CCD56FC49B"
- 我的异常处理三之net.sf.json.JSONException: Unquotted string
- JSON转换出现错误:net.sf.json.JSONException: Unterminated string at character 38 of
- JSON转换出现错误:net.sf.json.JSONException: Unterminated string at character 38 of
- Unquotted string 错误
- java的date类型无法读取 出现错误net.sf.json.JSONException: java.lang.reflect.InvocationTargetException
- JSON格式的String 怎么转成 net.sf.json.JSONObject
- JSON格式的String 转成 net.sf.json.JSONObject
- json-lib 出现net.sf.json.JSONException: There is a cycle in the hierarchy异常的解决办法
- json-lib 出现net.sf.json.JSONException: There is a cycle in the hierarchy异常的解决办法
- java.lang.NoClassDefFoundError: net/sf/json/JSONObject异常的解决办法
- 错误: java.io.NotSerializableException: net.sf.json.JSONObject 的解决方法
- net.sf.json的使用
- Json用法三个常见错误2 Javabean Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethod
- 使用json发生java.lang.NoClassDefFoundError: net/sf/json/JSONObject异常的解决办法
- 让QLabel自动换行
- 触屏反馈开关
- joseph_lee---android的jni
- ExpandableListView可扩展的下拉列表简单的使用
- SPI时序详解
- Feign 调用出现的net.sf.json.exception:Unquotted String错误,解决办法。
- ITK-4.10编译+VS2010+win32
- innosetup多语言选择,可添加多个
- Eclipse异常: 找不到或无法加载主类或项目无法编译10种解决大法
- 第26章 FMC—扩展外部SDRAM—零死角玩转STM32-F429系列
- Javascript中的高阶函
- difference between VM, Docker and Vagrant区别
- margin系列之百分比
- Solr初步探索(二)