Controller layer receives JSON data GBK garbled problem solving

@RequestMapping(value = "test", method = RequestMethod.POST)
    public Result receive(HttpServletRequest request) throws UnsupportedEncodingException {
        InputStream is = null;
        StringBuilder sb = new StringBuilder();
        try {
            is = request.getInputStream();
            byte[] b = new byte[4096];
            for (int n; (n = is.read(b)) != -1; ) {
                sb.append(new String(b, 0, n, "GBK"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (null != is) {
                try {
                    is.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        LOGGER.info("接收到原始信息{}", sb);
}

Guess you like

Origin blog.csdn.net/2301_76354366/article/details/130279679