1 2 3 4 5 6 | protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); } |
1 2 3 4 5 6 7 | Tomcat server.xml <Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true"> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | private static void createCsvFile() { try { FileOutputStream fos = new FileOutputStream("c:\\test.csv"); String str ="姓名,性别,年龄,出生年月"; fos.write(new byte[]{(byte)0xEF,(byte)0xBB, (byte)0xBF}); OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); BufferedWriter b_writer = new BufferedWriter(osw); b_writer.write(str); b_writer.close(); } catch (IOException e) { System.out.println(e.toString()); } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |