struts json result乱码问题

JSONUtil.writeJSONToResponse(SerializationParams serializationParams)
...
try {
    out = new GZIPOutputStream(response.getOutputStream());
    in = new ByteArrayInputStream(json.getBytes());
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    }
} finally {
    if (in != null)
        in.close();
    if (out != null) {
        out.finish();
        out.close();
    }
}
...

上面第4行改为如下代码:
in = new ByteArrayInputStream(json.getBytes(serializationParams.getEncoding())); 

你可能感兴趣的:(java,json,struts)