1、确保jsp页面编码是UTF-8
String code = "中";
byte[] temp = code.getBytes();
//将字符串转成UTF-8编码
String firCode = new String(temp, "UTF-8");
InputStream resultStream = new ByteArrayInputStream(new String(firCode.getBytes());
2、设置返回页面的字符编码
this.getResponse().setCharacterEncoding("GBK");