2008-03-06
编码之 xml 输出
Document resDocument = new Document(resElement);
response.setContentType("application/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Charset","Gb2312");
XMLOutputter xoutput=new XMLOutputter(Format.getPrettyFormat().setEncoding("Gb2312"));
xoutput.output(resDocument, System.out);
xoutput.output(resDocument, response.getOutputStream());//
区别xoutput.output(resDocument, response.getWriter());
response.setContentType("application/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Charset","Gb2312");
XMLOutputter xoutput=new XMLOutputter(Format.getPrettyFormat().setEncoding("Gb2312"));
xoutput.output(resDocument, System.out);
xoutput.output(resDocument, response.getOutputStream());//
区别xoutput.output(resDocument, response.getWriter());
评论
beyondsanli
2008-03-06
回复
当你写文件的时候不要用writer, 应该用outPutStream. writer会自动把String 转换成系统却省的encoding. 因为你的系统是中文的,所以你看到的总是GB2312或者GBK.
发表评论
我的相册
CIMG0924
共 34 张
共 34 张
链接
最新评论
-
C3P0连接池的相关配置
c3p0使用实例 public class DBConn   ...
-- by beyondsanli -
优秀员工感想
写的很有内涵我很喜欢 挺有特色的
-- by blucedong -
编码之上传下载
import java.io.UnsupportedEncodingExcept ...
-- by beyondsanli -
由功夫熊猫想到的
评论转载自:http://bbs.gxsd.com.cn/viewthread. ...
-- by beyondsanli -
由功夫熊猫想到的
评论转载自:http://bbs.gxsd.com.cn/viewthread. ...
-- by beyondsanli







评论排行榜