<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[iframe跨域传值超过2M的问题解决]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Thu, 11 Sep 2014 10:20:15 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	iframe跨域传值超过2M的问题解决<br/>使用iframe进行传值时，如果采用URL的方式传递，则最大只能传递大约2k的数据，超过这个长度就会被截断了，那么是否可以采用post的方式传值呢？答案是可以的，我们可以采用js创建一个form表单，并将此form提交到iframe上，这样就能做到打破2k数据的限制。<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;iframe id=&quot;frame1&quot; name=&quot;frame1&quot; src=&quot;&quot; style=&quot;display:none&quot;&gt;&lt;/iframe&gt;&nbsp;&nbsp;
&lt;script&gt;&nbsp;&nbsp;
var tranVal = function()&#123;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById(&quot;frame1&quot;).style.display = &quot;block&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;var postForm = document.createElement(&quot;form&quot;);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;postForm.method = &quot;post&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;postForm.action = &quot;http://localhost:8080/test/getdata.jsp&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;postForm.target = &quot;frame1&quot;;//用来将数据提交到frame1上&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;var input = document.createElement(&quot;input&quot;);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;input.type = &quot;hidden&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;input.name = &quot;username&quot;;//这个是传值的名称，要记住&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;var strA = &quot;1234567890&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;//循环500000次后，保证字符串的大小大于2M&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;for(var i=0;i&lt;500000;i++) strA+= &quot;1234567890&quot;;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;input.value = strA;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;postForm.appendChild(input);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;document.body.appendChild(postForm);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;postForm.submit();&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;//用完之后，不要忘记删掉&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;postForm.removeChild(input);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;document.body.removeChild(postForm);&nbsp;&nbsp;
&#125;&nbsp;&nbsp;
&lt;/script&gt;&nbsp;&nbsp;
&lt;button onclick=&quot;tranVal()&quot;&gt;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;传递值&nbsp;&nbsp;
&lt;/button&gt; 
</textarea><br/><br/>还需要注意2个问题： <br/><br/>1 tomcat下post不能超过2M的问题<br/>这个需要将tomcat的配置文件server.xml修改一下：<br/>&lt;Connector connectionTimeout=&quot;20000&quot; port=&quot;8080&quot; protocol=&quot;HTTP/1.1&quot; redirectPort=&quot;8443&quot; maxPostSize=&quot;0&quot;/&gt; <br/> maxPostSize为0时，表示不用限制长度。<br/><br/>2 跨域的问题<br/>跨域不影响iframe的post传值，发送方的tomcat无需更改，只是需要将接收方的tomcat的maxPostSize修改为0即可。<br/><br/>来自:http://housen1987.iteye.com/blog/1695065
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] iframe跨域传值超过2M的问题解决]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>