JsonParseException:无效的UTF-8起始字节0xbc

时间:2018-11-20 06:10:55

标签: spring

当我使用curl发布一些数据时:

function c () {
  // var D = 1542695151752 // 14:31
  // var D = 1542684151000 // 11:22
  // var D = 1542645151000 // 00:32
  var D = 1542667151000 // 6:39

  var S = 8
  var E = 17

  var A = new Date(D)
  var B = new Date(D + 1000 * 60 * 60 * 4)

  var Ah = A.getHours()
  var Bh = B.getHours()

  var NE
  var NS

  if (Ah >= S && Ah <= E && Bh >= S && Bh <= E) return (Math.abs(B - A)) / 1000 / 60 / 60
  if ((Ah < S || Ah > E) && (Bh < S || Bh > E)) return (0)

  if (Ah >= S && Ah <= E) {
    NS = A
    NE = new Date(B.getTime())
    NE.setHours(E)
    NE.setMinutes(0)
    NE.setSeconds(0)
  }

  if (Bh >= S && Bh <= E) {
    NE = B
    NS = new Date(A.getTime())
    NS.setHours(S)
    NS.setMinutes(0)
    NS.setSeconds(0)
  }
  return (Math.abs(NS - NE) / 1000 / 60)
}

console.log(c())

当服务器解析中文单词(ASCII代码可以)时,抛出此错误:

curl 'http://localhost:28082/inapi/reportingXzxkBeta' -H 'HL-APP-KEY: CreditSharePortal' -H 'Origin: http://localhost:3801' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' -H 'Referer: http://localhost:3801/main/reporting/reportXk' -H 'HL-CURRENT-URL: http://localhost:3801/main/reporting/reportXk' -H 'Cookie: cc-o-t-v3=4F315C6567FF8C7D9861AC62421F8536C6E7431D23C2A961A279698295C9427C88F5A35DDE872E2D545A2BCEFB2B836EBE71BA73B3D2E8BB27D275776D8C00B0E4EA7FDE501C09811CB553B6008EE49A; cc-email-v3=""' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary $'{"xzxdr":"ddd","ztLx":"护照","ztDm":"3445435243","xzxkJdswh":"34343","xkmc":"343434","zt":"正常","xknr":"d\'d","xklb":"普通","fddbrxm":"ddd","xkjdrq":"2018-11-20","xkjzq":"2018-11-20","dfbm":"500000","orgName":"东方广","xklbmc":"普通"}' --compressed

当我在服务器上的Liunx操作系统(默认操作系统编码为UTF-8)中运行此应用程序时,没问题。但是当我在Windows机器上调试时,它会崩溃(Intellij Idea Ultimate + Java 8 +嵌入式Tomcat)。也许操作系统默认编码GBK会导致此问题。如何解决此问题?我正在尝试在application.properties上添加此配置。

JsonParseException: Invalid UTF-8 start byte 0xbc

但这不起作用。

0 个答案:

没有答案