1

我用过

StringWriter writer = new StringWriter();
request.setCharacterEncoding("ISO-8859-1");
response.setContentType("text/html;charset=ISO-8859-1");
pw =response.getWriter();
IOUtils.copy(sImage, writer);
theString = writer.toString();
pw.write(theString);
pw.flush();

在客户端浏览器中,输出为

ÿþ<.h.t.m.l. x.m.l.n.s.:.v.=.".u.r.n.:.s.c.h.e.m.a s.-.m.i.c.r.o.s.of.t.-.c.o.m.:.v.m.l."...x.m.l.n s�:�o�=�"�u�r�n�:�s�c�h�e�m�s�-�m�c�r�o�s�of� t.-.c.o.m.:.of.f.i.c.e.:.of.f.f.i.c.e.". x.m.l.n s�:�w�=�"�u�r�n�:�s�c�h�e�m�a�s�-�m�c�r�o�s�of� t.-.c.o.m.:.of.f.i.c.e.:.w.o.r.d.". x.m.l.n.s.:' x�=�"�u�r�n�:�s�c�h�e�m�a�s�-�m�i�c�r�o�of�t�-� c.o.m.:.of.f.i.c.e.:.e.x.c.e.l.". x.m.l.n.s:.p. =�"�u�r�n�:�s�c�h�e�m�s�-�m�i�c�r�o�f�t�-�c o.m.:.of.f.i.c.e.:.p.o.w.e.r.p.o.i.n.t.". x.m.l' n.s.:.a.=.".u.r.n.:.s.c.h.e.m.a.s.-.m.i.c.r.o.s.o. f.t.-c.o.m.:.of.f.f.i.c.e.:.a.c.c.e.s.". �

如果你们中的任何人都知道这一点,我该如何解决这个问题

4

1 回答 1

1

尝试使用这个:

response.setContentType("text/html; charset=UTF-16LE");

当然,它不会使您的文本成为 ISO-8859-1,但是,现在大多数浏览器都支持 UTF-16 没有问题。

于 2010-11-11T03:47:48.620 回答