rt,用了一个HttpServletResponseWrapper的子类A来作为forward 的第二个参数
response.setCharacterEncoding(CharEncoding.UTF_8);
request.getRequestDispatcher("xxx")
.forward(request, HttpServletResponseWrapper's instance);
这个A封装了个ByteArrayOutputStream的一个实例,定义了个方法(比如getHtml())获取最后的html输出
现在调用getHtml(),发现里面中文乱码(全是?,英文正常)
而这样
request.getRequestDispatcher("xxx")
.forward(request, HttpServletResponse's instance);
就不是乱码(浏览器查看效果)
想知道什么情况导致这个问题的出现
注:
我的需求只是获取JSP渲染完后的html字符串,后台springmvc,不知道有没有其他方法可以取到html
检查一下gethtml()方法中字符集的设置。