alertmanager推送给第三方时出现中文乱码

写了一个接收post请求的rest接口,将post来的Json格式的告警接受为String格式的数据,如下:

@RequestBody String resourcesJson

通过这样的方式接受会使中文部分出现乱码。

解决方案:

resourcesJson =  new String(resourcesJson.getBytes("iso-8859-1"),"utf-8");

转码之后再对字符串进行Json解析,推荐:import com.alibaba.fastjson.JSON;

猜你喜欢

转载自blog.csdn.net/weixin_38645718/article/details/86699233
今日推荐