??xml version="1.0" encoding="utf-8" standalone="yes"?>国产欧美一区二区在线观看,日韩av综合中文字幕,亚洲成人a级网http://www.aygfsteel.com/dongisland/把握每一天的_ֽzh-cnThu, 22 May 2025 10:00:04 GMTThu, 22 May 2025 10:00:04 GMT60java求连l子数组的和最?/title><link>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410637.html</link><dc:creator>dongisland</dc:creator><author>dongisland</author><pubDate>Wed, 05 Mar 2014 03:47:00 GMT</pubDate><guid>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410637.html</guid><wfw:comment>http://www.aygfsteel.com/dongisland/comments/410637.html</wfw:comment><comments>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410637.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/dongisland/comments/commentRss/410637.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/dongisland/services/trackbacks/410637.html</trackback:ping><description><![CDATA[<p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; line-height: 18.850000381469727px;"><strong style="margin: 0px; padding: 0px;">题目描述Q?/strong><br style="margin: 0px; padding: 0px;" />输入一个整形数l,数组里有正数也有负数。数l中q箋的一个或多个整数l成一个子数组Q每个子数组都有一个和?/p><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; line-height: 18.850000381469727px;">求所有子数组的和的最大倹{要求时间复杂度为O(n)?/p><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; line-height: 18.850000381469727px;"><strong style="margin: 0px; padding: 0px;">思\Q?/strong></p><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; line-height: 18.850000381469727px;">我们可以使用分治法或者减L来处理这个问题?/p><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; line-height: 18.850000381469727px;"><strong style="margin: 0px; padding: 0px;">分治?   <br /></strong><span style="font-style: italic;">目标Q把1个大问题分成2个小问题Q?个小问题q可以再分,直到问题规模的可以单解冟?br /></span></p><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; font-style: italic; line-height: 18.850000381469727px;">该数组{分成两个子数组Q假如知道左右两侧两个数l的各自的最大子数组和,那么整个数组的最大子数组和可能ؓ三种情况Q?/p><ul style="margin: 1.12em 0px 1.12em 40px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; font-style: italic; line-height: 18.850000381469727px;"><li style="margin: 0px 0px 0px 12px; padding: 0px;">右侧数组的最大子数组?/li><li style="margin: 0px 0px 0px 12px; padding: 0px;">左侧数组的最大子数组?/li><li style="margin: 0px 0px 0px 12px; padding: 0px;">左右两侧数组中间毗邻位置q接形成的子数组的和的最大|?6Q?Q?3Q?####5Q?6Q?Q?8Q左侧最大gؓ4Q右侧ؓ9Q中间毗M|从2?向两侧相加,得到中间毗邻子数l?Q?3Q?Q?Q?6Q?和ؓ11Q三者比较得最大子数组和ؓ11Q?/li></ul><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; font-style: italic; line-height: 18.850000381469727px;">递归到数l中只包含一个数字?/p><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; font-style: italic; line-height: 18.850000381469727px;">q种思\也是可行的。进行ln(n)ơ拆分,每次拆分后进行nơ比较,所以算法复杂度为n*ln(n)。但q达不到题目的要求?/p><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; font-style: italic; line-height: 18.850000381469727px;">java代码Q?br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">package</span> com.island.info;<br /><span style="color: #008080; "> 2</span> <span style="color: #008000; ">/**</span><span style="color: #008000; "><br /></span><span style="color: #008080; "> 3</span> <span style="color: #008000; "> * <p>Title: TestMaxArray.java</p><br /></span><span style="color: #008080; "> 4</span> <span style="color: #008000; "> * <p>Description: 分治法求解连l和最?lt;/p><br /></span><span style="color: #008080; "> 5</span> <span style="color: #008000; "> * @date 2014-3-05<br /></span><span style="color: #008080; "> 6</span> <span style="color: #008000; "> *<br /></span><span style="color: #008080; "> 7</span> <span style="color: #008000; "> </span><span style="color: #008000; ">*/</span><br /><span style="color: #008080; "> 8</span>  <br /><span style="color: #008080; "> 9</span> <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">class</span> MaxSub {<br /><span style="color: #008080; ">10</span>         <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">int</span> arr[] = {4,-3,5,-2,-1,2,6,-2};    <span style="color: #008000; ">//</span><span style="color: #008000; ">也可以随机生?/span><span style="color: #008000; "><br /></span><span style="color: #008080; ">11</span> <span style="color: #008000; "></span>        <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">void</span> main(String args[]){<br /><span style="color: #008080; ">12</span>             System.out.println(max(arr));<br /><span style="color: #008080; ">13</span>         }<br /><span style="color: #008080; ">14</span>  <br /><span style="color: #008080; ">15</span>         <span style="color: #008000; ">//</span><span style="color: #008000; ">包装函数</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">16</span> <span style="color: #008000; "></span>        <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">int</span> max(<span style="color: #0000FF; ">final</span> <span style="color: #0000FF; ">int</span>[] arr){<br /><span style="color: #008080; ">17</span>             System.out.println("(1)*****arr.length-1----------------->:"+ (arr.length-1));<br /><span style="color: #008080; ">18</span>             <span style="color: #0000FF; ">return</span> max(arr,0,arr.length-1);<br /><span style="color: #008080; ">19</span>         }<br /><span style="color: #008080; ">20</span>  <br /><span style="color: #008080; ">21</span>         <span style="color: #008000; ">//</span><span style="color: #008000; ">核心代码Q递归调用max()</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">22</span> <span style="color: #008000; "></span>        <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">int</span> max(<span style="color: #0000FF; ">final</span> <span style="color: #0000FF; ">int</span>[] arr,<span style="color: #0000FF; ">int</span> leftIndex, <span style="color: #0000FF; ">int</span> rightIndex){<br /><span style="color: #008080; ">23</span>             System.out.println("(2)*****leftIndex--------rightIndex--->:"+leftIndex+"|***************|"+rightIndex);<br /><span style="color: #008080; ">24</span>             <span style="color: #0000FF; ">int</span> sum = 0,leftHalfMax = 0, rightHalfMax = 0;<br /><span style="color: #008080; ">25</span>             <span style="color: #0000FF; ">if</span> (rightIndex-leftIndex==0){<br /><span style="color: #008080; ">26</span>                 <span style="color: #0000FF; ">return</span> arr[rightIndex];<br /><span style="color: #008080; ">27</span>             } <span style="color: #0000FF; ">else</span> {<br /><span style="color: #008080; ">28</span>                 <span style="color: #0000FF; ">int</span> center = (leftIndex+rightIndex)/2;<span style="color: #008000; ">//</span><span style="color: #008000; ">2分查找中间节?/span><span style="color: #008000; "><br /></span><span style="color: #008080; ">29</span> <span style="color: #008000; "></span>                <span style="color: #0000FF; ">int</span> maxLeft = max(arr,leftIndex,center);<span style="color: #008000; ">//</span><span style="color: #008000; ">左边最大的</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">30</span> <span style="color: #008000; "></span>                <span style="color: #0000FF; ">int</span> maxRight = max(arr,center+1,rightIndex);<span style="color: #008000; ">//</span><span style="color: #008000; ">双最大的<br /></span><span style="color: #008080; ">31</span> <span style="color: #008000; ">                </span><span style="color: #008000; ">//</span><span style="color: #008000; ">以下是查找跨中间点的最大子序列<br /></span><span style="color: #008080; ">32</span> <span style="color: #008000; ">                </span><span style="color: #008000; ">//</span><span style="color: #008000; ">从中点到左侧Q?/span><span style="color: #008000; "><br /></span><span style="color: #008080; ">33</span> <span style="color: #008000; "></span>                <span style="color: #0000FF; ">for</span> (<span style="color: #0000FF; ">int</span> i=center;i>=leftIndex;--i){<br /><span style="color: #008080; ">34</span>                     sum+=arr[i];<br /><span style="color: #008080; ">35</span>                     <span style="color: #0000FF; ">if</span> (sum>leftHalfMax){<br /><span style="color: #008080; ">36</span>                         leftHalfMax = sum;<br /><span style="color: #008080; ">37</span>                     }<br /><span style="color: #008080; ">38</span>                 }<br /><span style="color: #008080; ">39</span>                 System.out.println("左边的sum----------->:"+sum);<br /><span style="color: #008080; ">40</span>                 sum=0;<br /><span style="color: #008080; ">41</span>                 <span style="color: #008000; ">//</span><span style="color: #008000; ">从中点到右侧</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">42</span> <span style="color: #008000; "></span>                <span style="color: #0000FF; ">for</span> (<span style="color: #0000FF; ">int</span> i=center+1;i<=rightIndex;++i){<br /><span style="color: #008080; ">43</span>                     sum+=arr[i];<br /><span style="color: #008080; ">44</span>                     <span style="color: #0000FF; ">if</span> (sum>rightHalfMax){<br /><span style="color: #008080; ">45</span>                         rightHalfMax = sum;<br /><span style="color: #008080; ">46</span>                     }<br /><span style="color: #008080; ">47</span>                 }<br /><span style="color: #008080; ">48</span>                 System.out.println("双的sum----------->:"+sum);<br /><span style="color: #008080; ">49</span>                 <span style="color: #0000FF; ">return</span> max(maxLeft,maxRight,leftHalfMax+rightHalfMax);<br /><span style="color: #008080; ">50</span>             }<br /><span style="color: #008080; ">51</span>         }<br /><span style="color: #008080; ">52</span>  <br /><span style="color: #008080; ">53</span>         <span style="color: #008000; ">//</span><span style="color: #008000; ">三者取最大?/span><span style="color: #008000; "><br /></span><span style="color: #008080; ">54</span> <span style="color: #008000; "></span>        <span style="color: #0000FF; ">public</span> <span style="color: #0000FF; ">static</span> <span style="color: #0000FF; ">int</span> max(<span style="color: #0000FF; ">int</span> a,<span style="color: #0000FF; ">int</span> b,<span style="color: #0000FF; ">int</span> c){<br /><span style="color: #008080; ">55</span>             <span style="color: #0000FF; ">return</span> a>b?(a>c?a:c):(b>c?b:c);<br /><span style="color: #008080; ">56</span>         }<br /><span style="color: #008080; ">57</span>     }</div><p style="margin: 1.12em 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; line-height: 18.850000381469727px;"><strong style="margin: 0px; padding: 0px;">减治?/strong></p><div><strong style="margin: 0px; padding: 0px; color: #555555; font-family: Helvetica, Arial, sans-serif, 微Y雅黑; font-size: small; line-height: 18.850000381469727px;"><p style="margin: 1.12em 0px; padding: 0px; font-style: italic; font-weight: normal;">目标Q将问题规模不断减小Q直到可以简单处理ؓ止?/p><p style="margin: 1.12em 0px; padding: 0px; font-style: italic; font-weight: normal;">假设我们已知一个数l的最大子数组和,现在在该数组后面增加一个数字,新数l的最大子数组和可能是什么呢Q?/p><ul style="margin: 1.12em 0px 1.12em 40px; padding: 0px; font-style: italic; font-weight: normal;"><li style="margin: 0px 0px 0px 12px; padding: 0px;">原数l的最大子数组和;</li><li style="margin: 0px 0px 0px 12px; padding: 0px;">新增加的数字为正敎ͼ和最右侧的子数组形成了一个新的最大子数组和(所以ؓ了通过一ơ遍历完成,我们需要保存最右侧的子数组的最大和Q?/li></ul><p style="margin: 1.12em 0px; padding: 0px; font-style: italic; font-weight: normal;">然后两个数字进行比较即可?/p><p style="margin: 1.12em 0px; padding: 0px; font-style: italic; font-weight: normal;">所以减治至数组只包含最左侧一个数字,我们知道它的最大子数组和和最右侧子数l最大和都ؓq数字,逐次?个数字直到整个数l即可?/p><p style="margin: 1.12em 0px; padding: 0px; font-style: italic; font-weight: normal;">java代码Q?br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #008080; "> 1</span> <span style="color: #0000FF; ">package</span><span style="color: #000000; "> com.island.info;<br /></span><span style="color: #008080; "> 2</span> <span style="color: #000000; "> <br /></span><span style="color: #008080; "> 3</span> <span style="color: #000000; "></span><span style="color: #008000; ">/**</span><span style="color: #008000; "><br /></span><span style="color: #008080; "> 4</span> <span style="color: #008000; "> * <p>Title: TestMaxArray.java</p><br /></span><span style="color: #008080; "> 5</span> <span style="color: #008000; "> * <p>Description: 分治法求解连l和最?lt;/p><br /></span><span style="color: #008080; "> 6</span> <span style="color: #008000; "> * @date 2014-3-05<br /></span><span style="color: #008080; "> 7</span> <span style="color: #008000; "> *<br /></span><span style="color: #008080; "> 8</span> <span style="color: #008000; "> </span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /></span><span style="color: #008080; "> 9</span> <span style="color: #000000; "></span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> MaxSubArraySum {<br /></span><span style="color: #008080; ">10</span> <span style="color: #000000; "> <br /></span><span style="color: #008080; ">11</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">long</span><span style="color: #000000; "> getMax(</span><span style="color: #0000FF; ">long</span><span style="color: #000000; "> a, </span><span style="color: #0000FF; ">long</span><span style="color: #000000; "> b) {<br /></span><span style="color: #008080; ">12</span> <span style="color: #000000; ">        </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> a </span><span style="color: #000000; ">></span><span style="color: #000000; "> b </span><span style="color: #000000; ">?</span><span style="color: #000000; "> a : b;<br /></span><span style="color: #008080; ">13</span> <span style="color: #000000; ">    }<br /></span><span style="color: #008080; ">14</span> <span style="color: #000000; ">     <br /></span><span style="color: #008080; ">15</span> <span style="color: #000000; ">    </span><span style="color: #008000; ">/**</span><span style="color: #008000; "> <br /></span><span style="color: #008080; ">16</span> <span style="color: #008000; ">    * 获得q箋子数l的最大和 <br /></span><span style="color: #008080; ">17</span> <span style="color: #008000; ">    * </span><span style="color: #808080; ">@param</span><span style="color: #008000; "> array <br /></span><span style="color: #008080; ">18</span> <span style="color: #008000; ">    * </span><span style="color: #808080; ">@return</span><span style="color: #008000; "> 最大和Q此处用了Long型是Z表示当参Cؓnull或空Ӟ可以q回nullQ返回其它Q何数字都可能引v歧义?nbsp;<br /></span><span style="color: #008080; ">19</span> <span style="color: #008000; ">    </span><span style="color: #008000; ">*/</span><span style="color: #000000; "> <br /></span><span style="color: #008080; ">20</span> <span style="color: #000000; "> <br /></span><span style="color: #008080; ">21</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> Long getMax(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">[] array) {<br /></span><span style="color: #008080; ">22</span> <span style="color: #000000; ">         <br /></span><span style="color: #008080; ">23</span> <span style="color: #000000; ">        </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (array </span><span style="color: #000000; ">==</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">null</span><span style="color: #000000; "> </span><span style="color: #000000; ">||</span><span style="color: #000000; "> array.length </span><span style="color: #000000; "><=</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">) {<br /></span><span style="color: #008080; ">24</span> <span style="color: #000000; ">            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">null</span><span style="color: #000000; ">;<br /></span><span style="color: #008080; ">25</span> <span style="color: #000000; ">        }<br /></span><span style="color: #008080; ">26</span> <span style="color: #000000; ">         <br /></span><span style="color: #008080; ">27</span> <span style="color: #000000; ">        </span><span style="color: #0000FF; ">long</span><span style="color: #000000; "> maxSum </span><span style="color: #000000; ">=</span><span style="color: #000000; "> array[</span><span style="color: #000000; ">0</span><span style="color: #000000; ">]; </span><span style="color: #008000; ">//</span><span style="color: #008000; ">所有子数组中最大的?nbsp;</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">28</span> <span style="color: #008000; "></span><span style="color: #000000; ">        </span><span style="color: #0000FF; ">long</span><span style="color: #000000; "> righteEdge </span><span style="color: #000000; ">=</span><span style="color: #000000; "> array[</span><span style="color: #000000; ">0</span><span style="color: #000000; ">]; </span><span style="color: #008000; ">//</span><span style="color: #008000; ">右侧子数l的最大和</span><span style="color: #008000; "><br /></span><span style="color: #008080; ">29</span> <span style="color: #008000; "></span><span style="color: #000000; ">        </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> i </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">; i </span><span style="color: #000000; "><</span><span style="color: #000000; "> array.length; i</span><span style="color: #000000; ">++</span><span style="color: #000000; ">) {<br /></span><span style="color: #008080; ">30</span> <span style="color: #000000; ">            </span><span style="color: #008000; ">//</span><span style="color: #008000; ">当右侧子数组的最大和数时Q对于新数组Q右侧子数组的最大和为新增加的数?nbsp; </span><span style="color: #008000; "><br /></span><span style="color: #008080; ">31</span> <span style="color: #008000; "></span><span style="color: #000000; ">            </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (righteEdge </span><span style="color: #000000; "><</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">) {<br /></span><span style="color: #008080; ">32</span> <span style="color: #000000; ">                righteEdge </span><span style="color: #000000; ">=</span><span style="color: #000000; "> array[i];<br /></span><span style="color: #008080; ">33</span> <span style="color: #000000; ">            } </span><span style="color: #0000FF; ">else</span><span style="color: #000000; "> { </span><span style="color: #008000; ">//</span><span style="color: #008000; ">为正数时Q对于新数组Q右侧子数组的最大和为新增加的数 + 原来的最大和?nbsp; </span><span style="color: #008000; "><br /></span><span style="color: #008080; ">34</span> <span style="color: #008000; "></span><span style="color: #000000; ">                righteEdge </span><span style="color: #000000; ">+=</span><span style="color: #000000; "> array[i];<br /></span><span style="color: #008080; ">35</span> <span style="color: #000000; ">            }<br /></span><span style="color: #008080; ">36</span> <span style="color: #000000; ">            </span><span style="color: #008000; ">//</span><span style="color: #008000; ">所有子数组中最大的?nbsp; </span><span style="color: #008000; "><br /></span><span style="color: #008080; ">37</span> <span style="color: #008000; "></span><span style="color: #000000; ">            System.out.println(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">righteEdge-------------maxSum:</span><span style="color: #000000; ">"</span><span style="color: #000000; ">+</span><span style="color: #000000; ">righteEdge</span><span style="color: #000000; ">+</span><span style="color: #000000; ">"</span><span style="color: #000000; ">****************</span><span style="color: #000000; ">"</span><span style="color: #000000; ">+</span><span style="color: #000000; ">maxSum);<br /></span><span style="color: #008080; ">38</span> <span style="color: #000000; ">            maxSum </span><span style="color: #000000; ">=</span><span style="color: #000000; "> getMax(righteEdge, maxSum);<br /></span><span style="color: #008080; ">39</span> <span style="color: #000000; ">        }<br /></span><span style="color: #008080; ">40</span> <span style="color: #000000; ">        </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> maxSum;<br /></span><span style="color: #008080; ">41</span> <span style="color: #000000; ">    }<br /></span><span style="color: #008080; ">42</span> <span style="color: #000000; "> <br /></span><span style="color: #008080; ">43</span> <span style="color: #000000; ">    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> main(String[] args) {<br /></span><span style="color: #008080; ">44</span> <span style="color: #000000; ">        </span><span style="color: #0000FF; ">int</span><span style="color: #000000; ">[] array </span><span style="color: #000000; ">=</span><span style="color: #000000; "> {</span><span style="color: #000000; ">1</span><span style="color: #000000; ">, </span><span style="color: #000000; ">-</span><span style="color: #000000; ">2</span><span style="color: #000000; ">, </span><span style="color: #000000; ">3</span><span style="color: #000000; ">, </span><span style="color: #000000; ">10</span><span style="color: #000000; ">, </span><span style="color: #000000; ">-</span><span style="color: #000000; ">4</span><span style="color: #000000; ">, </span><span style="color: #000000; ">7</span><span style="color: #000000; ">, </span><span style="color: #000000; ">2</span><span style="color: #000000; ">, </span><span style="color: #000000; ">-</span><span style="color: #000000; ">5</span><span style="color: #000000; ">};<br /></span><span style="color: #008080; ">45</span> <span style="color: #000000; ">        </span><span style="color: #008000; ">//</span><span style="color: #008000; ">int arr[] = {4,-3,5,-2,-1,2,6,-2};  </span><span style="color: #008000; "><br /></span><span style="color: #008080; ">46</span> <span style="color: #008000; "></span><span style="color: #000000; ">        System.out.println(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Max sum: </span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> MaxSubArraySum.getMax(array));<br /></span><span style="color: #008080; ">47</span> <span style="color: #000000; ">    }<br /></span><span style="color: #008080; ">48</span> <span style="color: #000000; "> <br /></span><span style="color: #008080; ">49</span> <span style="color: #000000; ">}</span></div></strong></div><img src ="http://www.aygfsteel.com/dongisland/aggbug/410637.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/dongisland/" target="_blank">dongisland</a> 2014-03-05 11:47 <a href="http://www.aygfsteel.com/dongisland/archive/2014/03/05/410637.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>单理解Ajax原理http://www.aygfsteel.com/dongisland/archive/2014/03/05/410633.htmldongislanddongislandWed, 05 Mar 2014 03:27:00 GMThttp://www.aygfsteel.com/dongisland/archive/2014/03/05/410633.htmlhttp://www.aygfsteel.com/dongisland/comments/410633.htmlhttp://www.aygfsteel.com/dongisland/archive/2014/03/05/410633.html#Feedback0http://www.aygfsteel.com/dongisland/comments/commentRss/410633.htmlhttp://www.aygfsteel.com/dongisland/services/trackbacks/410633.htmlAjax的原理就?通过javascript的方式,前台数据通过xmlhttp对象传递到后台Q后台在接收到请求后Q将需要的l果Q再传回到前収ͼq样可以实C需要页面的回发Q页是数据实现来回传递,从页实现无刷新?nbsp;
Ajax的原理简单来_实际上就是通过XmlHttpRequest对象来向服务器发异步hQ从服务器获得数据,然后用javascript来操作DOM而更新页面?nbsp;
q其中最关键的一步就是从服务器获得请求数据。要清楚q个q程和原理,我们必须?XMLHttpRequest有所了解?nbsp;
我们可以看出QXMLHttpRequest对象完全用来向服务器发出一个请求的Q它的作用也局限于此,但它的作用是整个ajax实现的关键,我们可以把服务器端看成一个数据接口,它返回的是一个纯文本,当然Q这个文本流可以是XML格式Q可以是HtmlQ可以是Javascript代码Q也可以只是一个字W串。这时候,XMLHttpRequest向服务器端请求这个页面,服务器端文本的l果写入面Q这和普通的web开发流E是一LQ不同的是,客户端在异步获取q个l果后,不是直接昄在页面,而是先由javascript来处理,然后再显C在面?/span>

dongisland 2014-03-05 11:27 发表评论
]]>
内外左右q接定义http://www.aygfsteel.com/dongisland/archive/2014/03/05/410631.htmldongislanddongislandWed, 05 Mar 2014 03:26:00 GMThttp://www.aygfsteel.com/dongisland/archive/2014/03/05/410631.htmlhttp://www.aygfsteel.com/dongisland/comments/410631.htmlhttp://www.aygfsteel.com/dongisland/archive/2014/03/05/410631.html#Feedback0http://www.aygfsteel.com/dongisland/comments/commentRss/410631.htmlhttp://www.aygfsteel.com/dongisland/services/trackbacks/410631.html内连接:INNER  JOIN或者JOINQ把两个表中数据对应的数据查出来?nbsp;
外连接:OUTER  JOINQ以某个表ؓ基础把对应数据查出来Q分为左外连接和叛_q接?nbsp;
左外q接QLEFT  JOIN或者LEFT  OUTER  JOINQ以某个表ؓ基础把对应数据查出来?nbsp;
叛_q接QRIGHT  JOIN或者RIGHT  OUTER  JOINQ以某个表ؓ基础把对应数据查出来?nbsp;
全连接:FULL  JOINQ以多个表ؓ基础

例子Q?  
   a?     id   name    
              1   ?                 
              2   李四                  
              3   王武                 

    b?    id     job   parent_id   
              1     23     1   
               2     34     2   
              3     34     4  
  a.id同b.parent_id   存在关系   
内连?/span>   
  select   a.*,b.*   from   a   inner   join   b     on   a.id=b.parent_id   
 l果?    
  1   ?          1     23     1   
  2   李四         2     34     2   
 左连?/span>   
  select   a.*,b.*   from   a   left   join   b     on   a.id=b.parent_id   
l果?    
  1   ?           1     23     1   
  2   李四          2     34     2   
  3   王武          null  
双?nbsp;  
  select   a.*,b.*   from   a   right   join   b     on   a.id=b.parent_id   
  l果?    
  1   ?            1     23     1   
  2   李四           2     34     2   
  null                 3     34     4   
  完全q接   
  select   a.*,b.*   from   a   full   join   b     on   a.id=b.parent_id  
  l果?    
  1   ?            1     23     1   
  2   李四           2     34     2   
  null                 3     34     4   
  3   王武           null

dongisland 2014-03-05 11:26 发表评论
]]>
谈JAVA集合 Map List Set{java集合c?/title><link>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410628.html</link><dc:creator>dongisland</dc:creator><author>dongisland</author><pubDate>Wed, 05 Mar 2014 03:07:00 GMT</pubDate><guid>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410628.html</guid><wfw:comment>http://www.aygfsteel.com/dongisland/comments/410628.html</wfw:comment><comments>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410628.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/dongisland/comments/commentRss/410628.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/dongisland/services/trackbacks/410628.html</trackback:ping><description><![CDATA[<p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="font-size: 10pt;"><strong>一、CollectionscdCollection接口</strong></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="font-family: Calibri; font-size: 10pt;">     Collections</span><span style="font-size: 10pt;">是针寚w合类的一个帮助类Q他提供一pd静态方法实现对各种集合的搜索、排序、线E安全化{操作?/span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="font-size: 10pt;">    Collection是最基本的集合接口,一个Collection代表一lObjectQ即Collection的元素(ElementsQ。一?Collection允许相同的元素而另一些不行。一些能排序而另一些不行。Java SDK不提供直接承自Collection?c,Java SDK提供的类都是l承自Collection?#8220;子接?#8221;如List和Set?/span><br /></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><strong style="font-size: 10pt;">二、现在来谈谈Java集合的一些实现类?/strong></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">Collection<br /></span></span><span style="font-size: 10pt;">├</span><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">List</span></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">│</span></span><span style="font-size: 10pt;">├</span><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">ArreyList </span></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">│</span></span><span style="font-size: 10pt;">├</span><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">Vector</span></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">│</span></span><span style="font-size: 10pt;">├</span><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">LinkedList</span></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">│└Stack</span></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">└Set</span></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">│</span></span><span style="font-size: 10pt;">├</span><span style="color: black;"><a title="java.util 中的c? style="color: #005880;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;"><u>HashSet</u></span></span></a><br /><span style="font-family: Calibri; font-size: 10pt;">│</span></span><span style="font-size: 10pt;">├</span><span style="color: black;"><a title="java.util 中的c? style="color: #005880;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;"><u>LinkedHashSet</u></span></span></a></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;">│└</span><a title="java.util 中的c? style="color: #005880;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;"><u>TreeSet</u></span></span></a></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;"><strong>List代表有序、重复的集合</strong></span></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="color: black;"></span></p><p style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;"><span style="font-size: 10pt;">1.ArrayListc?/span><br /><span style="font-size: 10pt;">  ArrayList实现了可变大的数组。它允许所有元素,包括null。ArrayList没有同步?/span><br /><span style="font-size: 10pt;">sizeQisEmptyQgetQsetҎq行旉为常数。但是addҎ开销为分摊的常数Q添加n个元素需要O(n)的时间。其他的Ҏq行旉为线性?/span><br /><span style="font-size: 10pt;">  每个ArrayList实例都有一个容量(CapacityQ,即用于存储元素的数组的大。这个容量可随着不断d新元素而自动增加,但是增长法 q没有定义。当需要插入大量元素时Q在插入前可以调用ensureCapacityҎ来增加ArrayList的容量以提高插入效率?/span><br /><span style="font-size: 10pt;">  和LinkedList一PArrayList也是非同步的QunsynchronizedQ?/span></p><div id="wmqeeuq" class="post"><div id="wmqeeuq" class="postbody" style="margin: 10px 15px 5px 0px; line-height: 26px;"><div class="wmqeeuq" id="blog_content"><p><span style="font-size: 10pt;">2.Vectorc?/span><br /><span style="font-size: 10pt;">  Vector非常cMArrayListQ但是Vector是同步的。由Vector创徏的IteratorQ虽然和ArrayList创徏的Iterator是同一接口Q但是,因ؓVector是同步的Q当一个Iterator被创且正在被用,另一个线E改变了Vector的状态(例如Q添加或删除了一些元素)Q这时调用Iterator的方法时抛出ConcurrentModificationExceptionQ因此必L莯异常?/span></p><p><span style="font-size: 10pt;">3.LinkedListc?/span><br /><span style="font-size: 10pt;">  LinkedList实现了List接口Q允许null元素。此外LinkedList提供额外的getQremoveQinsertҎ?LinkedList的首部或N。这些操作LinkedList可被用作堆栈QstackQ,队列QqueueQ或双向队列QdequeQ?/span><br /><span style="font-size: 10pt;">  注意LinkedList没有同步Ҏ。如果多个线E同时访问一个ListQ则必须自己实现讉K同步。一U解x法是在创建List时构造一个同步的ListQ?/span><br /><span style="font-size: 10pt;">    List list = Collections.synchronizedList(new LinkedList(...));</span></p><p><span style="font-size: 10pt;">4.Stack c?/span><br /><span style="font-size: 10pt;">  Stackl承自VectorQ实C个后q先出的堆栈。Stack提供5个额外的Ҏ使得Vector得以被当作堆栈用。基本的push和popҎQ还有peekҎ得到栈顶的元素,emptyҎ试堆栈是否为空QsearchҎ一个元素在堆栈中的位置。Stack刚创建后是空栈?/span></p><p><span style="font-size: 10pt;"><strong>Set代表无序、不可重复的集合</strong><br /><strong>HashSet和TreeSet的区?/strong><br />HashSet无序QTreeSet有序Q两者均不能有重复的对象<br /></span></p><p><span style="font-family: Calibri; font-size: 10pt;">Map<br /></span><span style="font-size: 10pt;">├</span><span style="font-family: Calibri; font-size: 10pt;">HashMap</span></p><p><span style="font-size: 10pt;">├</span><span style="font-family: Calibri; font-size: 10pt;">Hashtable</span></p><p><span style="font-size: 10pt;">├</span><a title="java.util 中的c? style="color: #005880;"><span style="color: black;"><span style="font-family: Calibri; font-size: 10pt;"><u>TreeMap</u></span></span></a><br /><span style="font-family: Calibri; font-size: 10pt;">└WeakHashMap</span></p><p><span style="font-size: 10pt;">Map没有l承Collection接口</span></p><p><span style="font-size: 10pt;">1.Hashtablec?/span><br /><span style="font-size: 10pt;">  Hashtablel承Map接口Q实C个key-value映射的哈希表。Q何非I(non-nullQ的对象都可作ؓkey或者value?/span><span style="font-size: 10pt;">Hashtable是同步的?/span></p><p><span style="font-size: 10pt;">2.HashMapc?/span><br /><span style="font-size: 10pt;">  HashMap和HashtablecMQ不同之处在?HashMap是非同步的,q且允许nullQ即null value和null key。,但是HashMap视ؓCollection?Qvalues()Ҏ可返回CollectionQ,其P代子操作旉开销和HashMap的容量成比例。因此,如果q代操作的性能相当重要的话Q不?HashMap的初始化定w讑־q高Q或者load factorq低?/span><br /><br /><span style="font-size: 10pt;">3.WeakHashMapc?/span><br /><span style="font-size: 10pt;">  WeakHashMap是一U改q的HashMapQ它对key实行“弱引?#8221;Q如果一个key不再被外部所引用Q那么该key可以被GC回收?/span></p><p><strong style="font-size: 10pt;">三、集合类的遍?/strong></p><p><span style="font-size: 10pt;">遍历通用<span style="font-family: Calibri; font-size: 10pt;">Collection</span></span></p><p><span style="font-size: 10pt;">Iterator it = collection.iterator(); // 获得一个P代子</span><br /><span style="font-size: 10pt;">  while(it.hasNext()) {</span><br /><span style="font-size: 10pt;">   Object obj = it.next(); // 得到下一个元?/span><br /><span style="font-size: 10pt;">}</span></p></div></div></div><img src ="http://www.aygfsteel.com/dongisland/aggbug/410628.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/dongisland/" target="_blank">dongisland</a> 2014-03-05 11:07 <a href="http://www.aygfsteel.com/dongisland/archive/2014/03/05/410628.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts1与Struts2的区?/title><link>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410627.html</link><dc:creator>dongisland</dc:creator><author>dongisland</author><pubDate>Wed, 05 Mar 2014 02:52:00 GMT</pubDate><guid>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410627.html</guid><wfw:comment>http://www.aygfsteel.com/dongisland/comments/410627.html</wfw:comment><comments>http://www.aygfsteel.com/dongisland/archive/2014/03/05/410627.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/dongisland/comments/commentRss/410627.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/dongisland/services/trackbacks/410627.html</trackback:ping><description><![CDATA[<span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">1) 在Action实现cL面的ҎQStruts 1要求Actioncȝ承一个抽象基c;Struts 1的一个具体问题是使用抽象cȝE而不是接口。Struts 2 Actioncd以实C个Action接口Q也可以实现其他接口Q可选和定制的服务成为可能。Struts 2提供一个ActionSupport基类d现常用的接口。即使Action接口不是必须实现的,只有一个包含executeҎ的POJOc都可以用作Struts 2的Action?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">2) U程模式斚w的对比:Struts 1 Action是单例模式ƈ且必LU程安全的,因ؓ仅有Action的一个实例来处理所有的h。单例策略限制了Struts 1 Action能做的事Qƈ且要在开发时特别心。Action资源必须是线E安全的或同步的QStruts 2 Action对象为每一个请求生一个实例,因此没有U程安全问题?即struts1每个action只有1个实例,struts2每一个请求都会new一个实例,所以struts2是线E安全的</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">3) Servlet依赖斚w的对比:Struts 1 Action依赖于Servlet APIQ因为Struts 1 Action的executeҎ中有HttpServletRequest和HttpServletResponseҎ。Struts 2 Action不再依赖于Servlet APIQ从而允许ActionqWeb容器q行Q从而降低了试Action的难度?当然Q如果Action需要直接访问HttpServletRequest和HttpServletResponse参数QStruts 2 Action仍然可以讉K它们。但是,大部分时候,Action都无需直接讉KHttpServetRequest和HttpServletResponseQ从而给开发者更多灵zȝ选择?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">4) 可测性方面的ҎQ测试Struts 1 Action的一个主要问题是executeҎ依赖于Servlet APIQ这使得Action的测试要依赖于Web容器。ؓ了脱Web容器试Struts 1的ActionQ必d助于第三方扩展QStruts TestCaseQ该扩展下包含了pd的Mock对象Q模拟了HttpServetRequest和HttpServletResponse对象Q,从而可以脱Web容器试Struts 1的ActioncRStruts 2 Action可以通过初始化、设|属性、调用方法来试?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">5) 装h参数的对比:Struts 1使用ActionForm对象装用户的请求参敎ͼ所有的ActionForm必须l承一个基c:ActionForm。普通的JavaBean不能用作ActionFormQ因此,开发者必d建大量的ActionFormcd装用戯求参数。虽然Struts 1提供了动态ActionForm来简化ActionForm的开发,但依焉要在配置文g中定义ActionFormQStruts 2直接使用Action属性来装用户h属性,避免了开发者需要大量开发ActionFormcȝ烦琐Q实际上Q这些属性还可以是包含子属性的Rich对象cd。如果开发者依然怀念Struts 1 ActionForm的模式,Struts 2提供了ModelDriven模式Q可以让开发者用单独的Model对象来封装用戯求参敎ͼ但该Model对象无需l承MStruts 2基类Q是一个POJOQ从而降低了代码污染?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">6) 表达式语a斚w的对比:Struts 1整合了JSTLQ因此可以用JSTL表达式语a。这U表辑ּ语言有基本对象图遍历Q但在对集合和烦引属性的支持上则功能不强QStruts 2可以使用JSTLQ但它整合了一U更强大和灵zȝ表达式语aQOGNLQObject Graph Notation LanguageQ,因此QStruts 2下的表达式语a功能更加强大?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">7) — l定值到视图的对比:Struts 1使用标准JSP机制把对象绑定到视图面QStruts 2使用“ValueStack”技术,使标{ֺ能够讉K|而不需要把对象和视N面绑定在一赗?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">8) cd转换的对比:Struts 1 ActionForm 属性通常都是Stringcd。Struts 1使用Commons-Beanutilsq行cd转换Q每个类一个{换器Q{换器是不可配|的QStruts 2使用OGNLq行cd转换Q支持基本数据类型和常用对象之间的{换?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">9) 数据校验的对比:Struts 1支持在ActionForm重写validateҎ中手动校验,或者通过整合Commons alidator框架来完成数据校验。Struts 2支持通过重写validateҎq行校验Q也支持整合XWork校验框架q行校验?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">10) Action执行控制的对比:Struts 1支持每一个模块对应一个请求处理(即生命周期的概念Q,但是模块中的所有Action必须׃n相同的生命周期。Struts 2支持通过拦截器堆栈(Interceptor StacksQؓ每一个Action创徏不同的生命周期。开发者可以根据需要创建相应堆栈,从而和不同的Action一起用?nbsp;</span><br style="color: #4d4d4d; font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 26px; background-color: #ffffff;" /><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;">11) 捕获输入QStruts1 使用ActionForm对象捕获输入。所有的ActionForm必须l承一个基cR因为其他JavaBean不能用作ActionFormQ开发者经常创建多余的cL莯入。动态BeanQDynaBeansQ可以作为创ZlActionForm的选择Q但是,开发者可能是在重新描q?创徏)已经存在的JavaBeanQ仍然会D有冗余的javabeanQ。Struts 2直接使用Action属性作入属性,消除了对W二个输入对象的需求。输入属性可能是有自??属性的rich对象cd。Action属性能够通过 web面上的taglibs讉K。Struts2也支持ActionForm模式。rich对象cdQ包括业务对象,能够用作输入/输出对象。这U?ModelDriven Ҏ简化了taglib对POJO输入对象的引用?/span><span style="color: #4d4d4d; font-size: 13px; line-height: 26px; font-family: Arial; background-color: #ffffff;"><br /></span><img src ="http://www.aygfsteel.com/dongisland/aggbug/410627.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/dongisland/" target="_blank">dongisland</a> 2014-03-05 10:52 <a href="http://www.aygfsteel.com/dongisland/archive/2014/03/05/410627.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ȫ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Զ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">»</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ȫ</a>| <a href="http://" target="_blank">J</a>| <a href="http://" target="_blank">¤</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">찲</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ξ</a>| <a href="http://" target="_blank">ʢ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">ԭ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>