response.setContentType("text/html;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); response.addHeader("Access-Control-Allow-Origin","*"); PrintWriter writer = null; try { writer = response.getWriter(); String json = JsonUtils.writer().writeValueAsString(rs);//自己封装的bean转json格式的String writer.print(json); } catch (IOException e) { e.printStackTrace(); }finally{ if(writer!=null){ writer.close(); } }