<?xml version="1.0" encoding="gb2312"?>

<!-- RSS generated by oioj.net on 4/16/2004 ; 感谢LeXRus提供 RSS 2.0 文档; 此文件可自由使用，但请保留此行信息 --> 
<!-- Source download URL: http://blogger.org.cn/blog/rss2.asp       -->
<rss version="2.0">

<channel>
<title>louisan的博客</title>
<link>http://blogger.org.cn/blog/blog.asp?name=louisan</link>
<description>louisan的博客</description>
<copyright>blogger.org.cn</copyright>
<generator>W3CHINA Blog</generator>
<webMaster>webmaster@blogger.org.cn</webMaster>
<item>
<title><![CDATA[DOJO的i/o系统]]></title>
<link>http://blogger.org.cn/blog/more.asp?name=louisan&amp;id=48265</link>
<author>louisan</author>
<pubDate>2010/2/24 10:03:14</pubDate>
<description><![CDATA[
<P>DOJO的i/o系统</P>
<P>&nbsp;&nbsp;&nbsp; 读者提示：水平有限，欢迎留言改正充实文章内容，并提出意见和建议。请不要书写与文章内容无关留言。</P>
<P>&nbsp;&nbsp;&nbsp; 正文：待</P>
<P><BR>&nbsp;&nbsp;&nbsp; 问题代码片段：</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;dojo.io.iframe.send({<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contentType: "multipart/form-data",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; form: dojo.byId('form1'),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url: "/test/upload/upload.do" ,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; method: "get" ,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handleAs: "html" ,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; handle: function(res, ioArgs){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dojo.style(result.domNode, {"height":"70%"});<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(res.body.textContent);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result.attr('content', res.body.textContent);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error: function(error){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;console.log(error);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; });&nbsp;&nbsp;&nbsp; </P>
<P>&nbsp;&nbsp;&nbsp; 问题描述：</P>
<P>&nbsp;&nbsp;&nbsp; 1 正常想要返回的是text格式的结果，但会报异常“<SPAN class="objectBox objectBox-string " role=presentation>ifd.getElementsByTagName("textarea")[0] is undefined”</SPAN></P>
<P><SPAN class="objectBox objectBox-string " role=presentation>&nbsp;&nbsp;&nbsp; 2&nbsp;返回中文结果时乱码</SPAN></P>
<P><SPAN class="objectBox objectBox-string " role=presentation></SPAN>&nbsp;&nbsp;&nbsp; 问题分析：</P>
<P>&nbsp;&nbsp;&nbsp; 1&nbsp;handleAs除非用html 类型（也可以是xml类型，请自行测试），其他类型会要求用&lt;textarea&gt;&lt;/textarea&gt;包装，否则会提示错误:ifd.getElementsByTagName("textarea")[0] is undefined</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;例如，后台返回结果：&nbsp; String result="&lt;textarea&gt;success成功&lt;/textarea&gt;";可会在页面出现个文本区域<BR></P>
<P>&nbsp; &nbsp;2 字符编码问题</P>
<P>&nbsp;&nbsp;&nbsp; 解决方法：</P>
<P>&nbsp;&nbsp;&nbsp; 1 handleAs采用html类型</P>
<P>&nbsp;&nbsp;&nbsp; 2&nbsp;</P>
<P>&nbsp;&nbsp;&nbsp; * 在服务器端转换返回结果的字符编码：</P>
<P>&nbsp;&nbsp;&nbsp; String result="success成功";<BR>&nbsp;&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result=new String(result.getBytes(request.getCharacterEncoding()),response.getCharacterEncoding());<BR>&nbsp;&nbsp;&nbsp; } catch (UnsupportedEncodingException e) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; <FONT color=#ff0000>或者</FONT></P>
<P>&nbsp;&nbsp;&nbsp; * 统一字符编码</P>
<P>&nbsp;&nbsp;&nbsp; response.setCharacterEncoding(request.getCharacterEncoding());</P>
<P>&nbsp;&nbsp;&nbsp; 疑问：定义的返回结果(result)为什么与request的编码(UTF-8)相同，而不是Charset.defaultCharset().name()，即GBK，是容器(Tomcat)的设置引起的？</P>]]></description>
</item>
</channel>
</rss>