HttpServletResponse在调用getWriter和getOutputStream两者之间之间只能选择一个,但有时已经调用过getOutputStream,仍然想调用getWriter,不难,用 java io 类嵌套一下就可以:
1 OutputStream out = null; 2 OutputStreamWriter ow = null; 3 4 out = resp.getOutputStream(); 5 ow = new OutputStreamWriter(out); 6 ow.append("你想要添加的东西");