http返回写入问题
1.服务器返回写的数据全是通过response对象,response.getWriter().print(msg);这样就返回写出数据了。
比如:
logger.info("encrypted: " + md5Encrypted); if(!md5Encrypted.equalsIgnoreCase(param.getSign())){ logger.info("sign invalid"); this.response(response, JSONObject.toJSONString(new ResultObject(ResultCode.SIGN_INVALID))); return; }else{ logger.info("valid sign success"); } }else{ this.response(response, JSONObject.toJSONString(new ResultObject(ResultCode.NULL_PARAM))); return; } //签名验证成功 chain.doFilter(requestWrapper, response); } private void response(ServletResponse response, String msg) throws IOException{ response.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8;"); response.getWriter().print(msg); response.flushBuffer(); }