??xml version="1.0" encoding="utf-8" standalone="yes"?>99国产欧美久久久精品,亚洲mv在线,国内精品久久久久久久影视蜜臀 http://www.aygfsteel.com/hellxoul/archive/2015/01/05/422054.htmlhellxoulhellxoulMon, 05 Jan 2015 03:52:00 GMThttp://www.aygfsteel.com/hellxoul/archive/2015/01/05/422054.htmlhttp://www.aygfsteel.com/hellxoul/comments/422054.htmlhttp://www.aygfsteel.com/hellxoul/archive/2015/01/05/422054.html#Feedback0http://www.aygfsteel.com/hellxoul/comments/commentRss/422054.htmlhttp://www.aygfsteel.com/hellxoul/services/trackbacks/422054.html阅读全文

hellxoul 2015-01-05 11:52 发表评论
]]>
研究SpringMvc 3.2?lt;mvc:annotation-driven>默认q了什?/title><link>http://www.aygfsteel.com/hellxoul/archive/2014/08/03/416500.html</link><dc:creator>hellxoul</dc:creator><author>hellxoul</author><pubDate>Sun, 03 Aug 2014 14:35:00 GMT</pubDate><guid>http://www.aygfsteel.com/hellxoul/archive/2014/08/03/416500.html</guid><wfw:comment>http://www.aygfsteel.com/hellxoul/comments/416500.html</wfw:comment><comments>http://www.aygfsteel.com/hellxoul/archive/2014/08/03/416500.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/hellxoul/comments/commentRss/416500.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/hellxoul/services/trackbacks/416500.html</trackback:ping><description><![CDATA[<span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.200000762939453px; background-color: #ffffff;">如果不配|其他参敎ͼ大致相当于以下的配置文gQ参考自org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParserQ?nbsp;<br /></span><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: #008000; "><!--</span><span style="color: #008000; "> 配置路径扩展名映的媒体cd </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">  2</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="pathExtensionContentNegotiationStrategy"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; ">  3</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.accept.PathExtensionContentNegotiationStrategy"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">  4</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">  5</span>       <span style="color: #0000FF; "><</span><span style="color: #800000; ">props</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">  6</span>         <span style="color: #008000; "><!--</span><span style="color: #008000; "> if romePresent </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">  7</span>         <span style="color: #0000FF; "><</span><span style="color: #800000; ">prop </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="atom"</span><span style="color: #0000FF; ">></span>application/atom+xml<span style="color: #0000FF; "></</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">  8</span>         <span style="color: #0000FF; "><</span><span style="color: #800000; ">prop </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="rss"</span><span style="color: #0000FF; ">></span>application/rss+xml<span style="color: #0000FF; "></</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">  9</span>         <span style="color: #008000; "><!--</span><span style="color: #008000; "> endif </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 10</span>         <span style="color: #008000; "><!--</span><span style="color: #008000; "> if jackson2Present || jacksonPresent </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 11</span>         <span style="color: #0000FF; "><</span><span style="color: #800000; ">prop </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="json"</span><span style="color: #0000FF; ">></span>application/json<span style="color: #0000FF; "></</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 12</span>         <span style="color: #008000; "><!--</span><span style="color: #008000; "> endif </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 13</span>         <span style="color: #008000; "><!--</span><span style="color: #008000; "> if jaxb2Present </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 14</span>         <span style="color: #0000FF; "><</span><span style="color: #800000; ">prop </span><span style="color: #FF0000; ">key</span><span style="color: #0000FF; ">="xml"</span><span style="color: #0000FF; ">></span>application/xml<span style="color: #0000FF; "></</span><span style="color: #800000; ">prop</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 15</span>         <span style="color: #008000; "><!--</span><span style="color: #008000; "> endif </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 16</span>       <span style="color: #0000FF; "></</span><span style="color: #800000; ">props</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 17</span>     <span style="color: #0000FF; "></</span><span style="color: #800000; ">constructor-arg</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 18</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 19</span> <br /><span style="color: #008080; "> 20</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> 配置映射媒体cd的策?nbsp;</span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 21</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="mvcContentNegotiationManager"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 22</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.accept.ContentNegotiationManager"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 23</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 24</span>       <span style="color: #0000FF; "><</span><span style="color: #800000; ">list</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 25</span>         <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="pathExtensionContentNegotiationStrategy"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 26</span>       <span style="color: #0000FF; "></</span><span style="color: #800000; ">list</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 27</span>     <span style="color: #0000FF; "></</span><span style="color: #800000; ">constructor-arg</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 28</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 29</span> <br /><span style="color: #008080; "> 30</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">class</span><span style="color: #0000FF; ">="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 31</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="order"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="0"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 32</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="removeSemicolonContent"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="false"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 33</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="contentNegotiationManager"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="mvcContentNegotiationManager"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 34</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 35</span> <br /><span style="color: #008080; "> 36</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> 配置数据转换服务Q默认用格式化数据转换服务Q可以对日期和数字进行格式化 </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 37</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="conversionService"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 38</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.format.support.DefaultFormattingConversionService"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 39</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg </span><span style="color: #FF0000; ">index</span><span style="color: #0000FF; ">="0"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 40</span>       <span style="color: #0000FF; "><</span><span style="color: #800000; ">null</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 41</span>     <span style="color: #0000FF; "></</span><span style="color: #800000; ">constructor-arg</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 42</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg </span><span style="color: #FF0000; ">index</span><span style="color: #0000FF; ">="1"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="true"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 43</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 44</span> <br /><span style="color: #008080; "> 45</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="validator"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 46</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 47</span> <br /><span style="color: #008080; "> 48</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> 配置数据l定Q通过转换服务实现l定Q如果包含jsr303实现q将q行校验 </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 49</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="webBindingInitializer"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 50</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.bind.support.ConfigurableWebBindingInitializer"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 51</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="conversionService"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="conversionService"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 52</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> if jsr303Present </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 53</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="validator"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="validator"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 54</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> endif </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 55</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 56</span> <br /><span style="color: #008080; "> 57</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="byteArrayHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 58</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.ByteArrayHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 59</span> <br /><span style="color: #008080; "> 60</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="stringHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 61</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.StringHttpMessageConverter"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 62</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="writeAcceptCharset"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="false"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 63</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 64</span> <br /><span style="color: #008080; "> 65</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="resourceHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 66</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.ResourceHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 67</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="sourceHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 68</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.xml.SourceHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 69</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="allEncompassingFormHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 70</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 71</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="atomFeedHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 72</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.feed.AtomFeedHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 73</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="rssChannelHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 74</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.feed.RssChannelHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 75</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="jaxb2RootElementHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 76</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 77</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="mappingJacksonHttpMessageConverter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 78</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 79</span> <br /><span style="color: #008080; "> 80</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> 配置@RequestBodyQ@ResponseBody注解可用的{换器 </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 81</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">util:list </span><span style="color: #FF0000; ">id</span><span style="color: #0000FF; ">="messageConverters"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; "> 82</span> <span style="color: #FF0000; ">             list-class</span><span style="color: #0000FF; ">="org.springframework.beans.factory.support.ManagedList"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 83</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="byteArrayHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 84</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="stringHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 85</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="resourceHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 86</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="sourceHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 87</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="allEncompassingFormHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 88</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> if romePresent </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 89</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="atomFeedHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 90</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="rssChannelHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 91</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> endif </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 92</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> if jaxb2Present </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 93</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="jaxb2RootElementHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 94</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> endif </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 95</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> if jacksonPresent </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 96</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">ref </span><span style="color: #FF0000; ">bean</span><span style="color: #0000FF; ">="mappingJacksonHttpMessageConverter"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; "> 97</span>     <span style="color: #008000; "><!--</span><span style="color: #008000; "> endif </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; "> 98</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">util:list</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; "> 99</span> <br /><span style="color: #008080; ">100</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> Q意类型的Controller适配为Handler </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">101</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="requestMappingHandlerAdapter"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; ">102</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">103</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="contentNegotiationManager"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="mvcContentNegotiationManager"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">104</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="webBindingInitializer"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="webBindingInitializer"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">105</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="messageConverters"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="messageConverters"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">106</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">107</span> <br /><span style="color: #008080; ">108</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> q个拦截器暴露{换器服务让spring:bind和spring:eval标签可用 </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">109</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="csInterceptor"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; ">110</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">111</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg </span><span style="color: #FF0000; ">index</span><span style="color: #0000FF; ">="0"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="conversionService"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">112</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">113</span> <br /><span style="color: #008080; ">114</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> 现在所有拦截器都必设定响应的路径映射 </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">115</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="mappedCsInterceptor"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; ">116</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.servlet.handler.MappedInterceptor"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">117</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg </span><span style="color: #FF0000; ">index</span><span style="color: #0000FF; ">="0"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">118</span>       <span style="color: #0000FF; "><</span><span style="color: #800000; ">null</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">119</span>     <span style="color: #0000FF; "></</span><span style="color: #800000; ">constructor-arg</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">120</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">constructor-arg </span><span style="color: #FF0000; ">index</span><span style="color: #0000FF; ">="1"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="csInterceptor"</span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">121</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">122</span> <br /><span style="color: #008080; ">123</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> 使用@ExceptionHandler注解的方法来处理ExceptionQ优先?Q最高) </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">124</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="exceptionHandlerExceptionResolver"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; ">125</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">126</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="contentNegotiationManager"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="mvcContentNegotiationManager"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">127</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="messageConverters"</span><span style="color: #FF0000; "> ref</span><span style="color: #0000FF; ">="messageConverters"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">128</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="order"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="0"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">129</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">130</span> <br /><span style="color: #008080; ">131</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> 如果抛出的Exceptioncd有@ResponseStatus注解Q响应返回该注解的Http状态码Q优先? </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">132</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="responseStatusExceptionResolver"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; ">133</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">134</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="order"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="1"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">135</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">136</span> <br /><span style="color: #008080; ">137</span>   <span style="color: #008000; "><!--</span><span style="color: #008000; "> SpringMvc内部异常处理 </span><span style="color: #008000; ">--></span><br /><span style="color: #008080; ">138</span>   <span style="color: #0000FF; "><</span><span style="color: #800000; ">bean </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="defaultExceptionResolver"</span><span style="color: #FF0000; "><br /></span><span style="color: #008080; ">139</span> <span style="color: #FF0000; ">        class</span><span style="color: #0000FF; ">="org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver"</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">140</span>     <span style="color: #0000FF; "><</span><span style="color: #800000; ">property </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">="order"</span><span style="color: #FF0000; "> value</span><span style="color: #0000FF; ">="2"</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/></span><br /><span style="color: #008080; ">141</span>   <span style="color: #0000FF; "></</span><span style="color: #800000; ">bean</span><span style="color: #0000FF; ">></span><br /><span style="color: #008080; ">142</span> </div><img src ="http://www.aygfsteel.com/hellxoul/aggbug/416500.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/hellxoul/" target="_blank">hellxoul</a> 2014-08-03 22:35 <a href="http://www.aygfsteel.com/hellxoul/archive/2014/08/03/416500.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Servlet生命周期http://www.aygfsteel.com/hellxoul/archive/2014/07/05/415484.htmlhellxoulhellxoulSat, 05 Jul 2014 07:21:00 GMThttp://www.aygfsteel.com/hellxoul/archive/2014/07/05/415484.htmlhttp://www.aygfsteel.com/hellxoul/comments/415484.htmlhttp://www.aygfsteel.com/hellxoul/archive/2014/07/05/415484.html#Feedback0http://www.aygfsteel.com/hellxoul/comments/commentRss/415484.htmlhttp://www.aygfsteel.com/hellxoul/services/trackbacks/415484.html1.容器加蝲c,调用servlet的无参构造方法,q调用servlet的init()Ҏ(gu)Q从而初始化servlet?br />2.init()在servlet一生中只调用一ơ,往往在servlet为客戯求提供服务之前调用?br />3.init()Ҏ(gu)使servlet可以讉KServletConfig和ServletContext对象Qservlet需要从q些对象得到有关servlet配置和web应用的信息?br />4.容器通过调用servlet的destroy()Ҏ(gu)来结束servlet的生?br />5.servlet一生的大多旉都是在ؓ(f)某个客户端请求运行service()Ҏ(gu)
6.对servlet的每个请求都在一个单独的U程中运行,M特定servletc都只有一个实例?br />

hellxoul 2014-07-05 15:21 发表评论
]]>
Guava学习(fn)W记QOrdering犀利的比较?/title><link>http://www.aygfsteel.com/hellxoul/archive/2014/07/03/415399.html</link><dc:creator>hellxoul</dc:creator><author>hellxoul</author><pubDate>Thu, 03 Jul 2014 02:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/hellxoul/archive/2014/07/03/415399.html</guid><wfw:comment>http://www.aygfsteel.com/hellxoul/comments/415399.html</wfw:comment><comments>http://www.aygfsteel.com/hellxoul/archive/2014/07/03/415399.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/hellxoul/comments/commentRss/415399.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/hellxoul/services/trackbacks/415399.html</trackback:ping><description><![CDATA[转自Q?span style="font-size: 14px;">http://www.cnblogs.com/peida/p/Guava_Ordering.html<br /></span><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">Ordering是Guavacd提供的一个犀利强大的比较器工PGuava的Ordering和JDK Comparator相比功能更强。它非常Ҏ(gu)扩展Q可以轻松构造复杂的comparatorQ然后用在容器的比较、排序等操作中?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  本质上来_(d)Ordering 实例无非是一个特D的Comparator 实例。Ordering只是需要依赖于一个比较器Q例如,Collections.maxQ的Ҏ(gu)Qƈ使其可作为实例方法。另外,Ordering提供了链式方法调用和加强现有的比较器?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  下面我们看看Ordering中的一些具体方法和单的使用实例?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  <strong style="margin: 0px; padding: 0px;">常见的静态方法:(x)</strong></p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  <strong style="margin: 0px; padding: 0px;">natural()Q?/strong>使用Comparablecd的自焉序, 例如Q整C到大,字符串是按字兔R?<br style="margin: 0px; padding: 0px;" />  <strong style="margin: 0px; padding: 0px;">usingToString() Q?/strong>使用toString()q回的字W串按字兔R序进行排序;<br style="margin: 0px; padding: 0px;" />  <strong style="margin: 0px; padding: 0px;">arbitrary() Q?/strong>q回一个所有对象的L序Q?即compare(a, b) == 0 是 a == b (identity equality)?本n的排序是没有M含义Q?但是在VM的生命周期是一个常量?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  单实例:(x)</p><div id="wmqeeuq" class="cnblogs_code" style="margin: 5px 0px; font-size: 12px !important;"><div id="wmqeeuq" class="cnblogs_code_toolbar" style="margin: 5px 0px 0px;"><span id="wmqeeuq" class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 0px; border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier New' !important;"><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> java.util.List; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> org.junit.Test; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> com.google.common.collect.Lists; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> com.google.common.collect.Ordering; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">public</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">class</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> OrderingTest { @Test </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">public</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">void</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> testStaticOrdering(){ List</span><String> list =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Lists.newArrayList(); list.add(</span>"peida"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"jerry"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"harry"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"eva"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"jhon"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"neron"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); System.out.println(</span>"list:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> list);<br style="margin: 0px; padding: 0px;" /> Ordering</span><String> naturalOrdering =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Ordering.natural(); Ordering</span><Object> usingToStringOrdering =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Ordering.usingToString(); Ordering</span><Object> arbitraryOrdering =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Ordering.arbitrary(); System.out.println(</span>"naturalOrdering:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.sortedCopy(list)); System.out.println(</span>"usingToStringOrdering:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> usingToStringOrdering.sortedCopy(list)); System.out.println(</span>"arbitraryOrdering:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> arbitraryOrdering.sortedCopy(list)); } }</span></pre><div id="wmqeeuq" class="cnblogs_code_toolbar" style="margin: 5px 0px 0px;"><span id="wmqeeuq" class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 0px; border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div></div><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  输出Q?/p><div id="wmqeeuq" class="cnblogs_code" style="margin: 5px 0px; font-size: 12px !important;"><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier New' !important;"><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">list:[peida, jerry, harry, eva, jhon, neron] naturalOrdering:[eva, harry, jerry, jhon, neron, peida] usingToStringOrdering:[eva, harry, jerry, jhon, neron, peida] arbitraryOrdering:[neron, harry, eva, jerry, peida, jhon]</span></pre></div><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  操作Ҏ(gu)Q?/p><p style="margin-top: 10px; margin-bottom: 10px; padding: 0px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 24px; background-color: #ffffff;">  reverse(): q回与当前Ordering相反的排?<br style="margin: 0px; padding: 0px;" />  nullsFirst(): q回一个将null攑֜non-null元素之前的OrderingQ其他的和原始的Ordering一P<br style="margin: 0px; padding: 0px;" />  nullsLast()Q返回一个将null攑֜non-null元素之后的OrderingQ其他的和原始的Ordering一P<br style="margin: 0px; padding: 0px;" />  compound(Comparator)Q返回一个用Comparator的OrderingQComparator作ؓ(f)W二排序元素Q例如对bug列表q行排序Q先Ҏ(gu)bug的别,再根据优先q行排序Q?br style="margin: 0px; padding: 0px;" />  lexicographical()Q返回一个按照字典元素P代的OrderingQ?br style="margin: 0px; padding: 0px;" />  onResultOf(Function)Q将function应用在各个元素上之后, 在用原始orderingq行排序Q?br style="margin: 0px; padding: 0px;" />  greatestOf(Iterable iterable, int k)Q返回指定的Wk个可q代的最大的元素Q按照这个从最大到最的序。是不稳定的?br style="margin: 0px; padding: 0px;" />  leastOf(Iterable<E> iterable,int k)Q返回指定的Wk个可q代的最的元素Q按照这个从最到最大的序。是不稳定的?br style="margin: 0px; padding: 0px;" />  isOrdered(Iterable)Q是否有序,Iterable不能于2个元素?br style="margin: 0px; padding: 0px;" />  isStrictlyOrdered(Iterable)Q是否严格有序。请注意QIterable不能于两个元素?br style="margin: 0px; padding: 0px;" />  sortedCopy(Iterable)Q返回指定的元素作ؓ(f)一个列表的排序副本?/p><div id="wmqeeuq" class="cnblogs_code" style="margin: 5px 0px; font-size: 12px !important;"><div id="wmqeeuq" class="cnblogs_code_toolbar" style="margin: 5px 0px 0px;"><span id="wmqeeuq" class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 0px; border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier New' !important;"><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">package</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> com.peidasoft.guava.base; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> java.util.List; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> org.junit.Test; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> com.google.common.collect.ImmutableList; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> com.google.common.collect.Lists; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">import</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> com.google.common.collect.Ordering; </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">public</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">class</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> OrderingTest { @Test </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">public</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">void</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> testOrdering(){ List</span><String> list =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Lists.newArrayList(); list.add(</span>"peida"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"jerry"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"harry"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"eva"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"jhon"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); list.add(</span>"neron"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); System.out.println(</span>"list:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> list); Ordering</span><String> naturalOrdering =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Ordering.natural(); System.out.println(</span>"naturalOrdering:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.sortedCopy(list)); List</span><Integer> listReduce=<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Lists.newArrayList(); </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">for</span>(<span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">int</span> i=9;i>0;i--<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">){ listReduce.add(i); } List</span><Integer> listtest=<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Lists.newArrayList(); listtest.add(</span>1<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); listtest.add(</span>1<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); listtest.add(</span>1<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); listtest.add(</span>2<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); Ordering</span><Integer> naturalIntReduceOrdering =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Ordering.natural(); System.out.println(</span>"listtest:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> listtest); System.out.println(naturalIntReduceOrdering.isOrdered(listtest)); System.out.println(naturalIntReduceOrdering.isStrictlyOrdered(listtest)); System.out.println(</span>"naturalIntReduceOrdering:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalIntReduceOrdering.sortedCopy(listReduce)); System.out.println(</span>"listReduce:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> listReduce); System.out.println(naturalIntReduceOrdering.isOrdered(naturalIntReduceOrdering.sortedCopy(listReduce))); System.out.println(naturalIntReduceOrdering.isStrictlyOrdered(naturalIntReduceOrdering.sortedCopy(listReduce))); Ordering</span><String> natural =<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> Ordering.natural(); List</span><String> abc = ImmutableList.of("a", "b", "c"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); System.out.println(natural.isOrdered(abc)); System.out.println(natural.isStrictlyOrdered(abc)); System.out.println(</span>"isOrdered reverse :"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> natural.reverse().isOrdered(abc)); List</span><String> cba = ImmutableList.of("c", "b", "a"<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); System.out.println(natural.isOrdered(cba)); System.out.println(natural.isStrictlyOrdered(cba)); System.out.println(cba </span>=<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> natural.sortedCopy(cba)); System.out.println(</span>"max:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">natural.max(cba)); System.out.println(</span>"min:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">natural.min(cba)); System.out.println(</span>"leastOf:"+natural.leastOf(cba, 2<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">)); System.out.println(</span>"naturalOrdering:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.sortedCopy(list)); System.out.println(</span>"leastOf list:"+naturalOrdering.leastOf(list, 3<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">)); System.out.println(</span>"greatestOf:"+naturalOrdering.greatestOf(list, 3<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">)); System.out.println(</span>"reverse list :"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.reverse().sortedCopy(list)); System.out.println(</span>"isOrdered list :"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.isOrdered(list)); System.out.println(</span>"isOrdered list :"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.reverse().isOrdered(list)); list.add(</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">null</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">); System.out.println(</span>" add null list:"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">list); System.out.println(</span>"nullsFirst list :"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.nullsFirst().sortedCopy(list)); System.out.println(</span>"nullsLast list :"+<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalOrdering.nullsLast().sortedCopy(list)); } } </span><span style="margin: 0px; padding: 0px; color: #008000; line-height: 1.5 !important;">//</span><span style="margin: 0px; padding: 0px; color: #008000; line-height: 1.5 !important;">============输出==============</span> <span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">list:[peida, jerry, harry, eva, jhon, neron] naturalOrdering:[eva, harry, jerry, jhon, neron, peida] listtest:[</span>1, 1, 1, 2<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">] </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">true</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">false</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> naturalIntReduceOrdering:[</span>1, 2, 3, 4, 5, 6, 7, 8, 9<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">] listReduce:[</span>9, 8, 7, 6, 5, 4, 3, 2, 1<span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">] </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">true</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">true</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">true</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">true</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> isOrdered reverse :</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">false</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">false</span> <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">false</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> [a, b, c] max:c min:a leastOf:[a, b] naturalOrdering:[eva, harry, jerry, jhon, neron, peida] leastOf list:[eva, harry, jerry] greatestOf:[peida, neron, jhon] reverse list :[peida, neron, jhon, jerry, harry, eva] isOrdered list :</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">false</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> isOrdered list :</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">false</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;"> add </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">null</span> list:[peida, jerry, harry, eva, jhon, neron, <span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">null</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">] nullsFirst list :[</span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">null</span><span style="margin: 0px; padding: 0px; line-height: 1.5 !important;">, eva, harry, jerry, jhon, neron, peida] nullsLast list :[eva, harry, jerry, jhon, neron, peida, </span><span style="margin: 0px; padding: 0px; color: #0000ff; line-height: 1.5 !important;">null</span>]</pre><div id="wmqeeuq" class="cnblogs_code_toolbar" style="margin: 5px 0px 0px;"><span id="wmqeeuq" class="cnblogs_code_copy" style="margin: 0px; padding: 0px 5px 0px 0px; line-height: 1.5 !important;"><a title="复制代码" style="margin: 0px; padding: 0px; border: none !important;"><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" style="margin: 0px; padding: 0px; border: none !important;" /></a></span></div></div><span style="font-size: 14px;"><br /></span><img src ="http://www.aygfsteel.com/hellxoul/aggbug/415399.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/hellxoul/" target="_blank">hellxoul</a> 2014-07-03 10:48 <a href="http://www.aygfsteel.com/hellxoul/archive/2014/07/03/415399.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>centOS6.5 rabbitmq安装http://www.aygfsteel.com/hellxoul/archive/2014/06/25/415135.htmlhellxoulhellxoulWed, 25 Jun 2014 14:23:00 GMThttp://www.aygfsteel.com/hellxoul/archive/2014/06/25/415135.htmlhttp://www.aygfsteel.com/hellxoul/comments/415135.htmlhttp://www.aygfsteel.com/hellxoul/archive/2014/06/25/415135.html#Feedback0http://www.aygfsteel.com/hellxoul/comments/commentRss/415135.htmlhttp://www.aygfsteel.com/hellxoul/services/trackbacks/415135.html阅读全文

hellxoul 2014-06-25 22:23 发表评论
]]>
数据库事务隔ȝ?/title><link>http://www.aygfsteel.com/hellxoul/archive/2014/06/15/414771.html</link><dc:creator>hellxoul</dc:creator><author>hellxoul</author><pubDate>Sun, 15 Jun 2014 07:15:00 GMT</pubDate><guid>http://www.aygfsteel.com/hellxoul/archive/2014/06/15/414771.html</guid><wfw:comment>http://www.aygfsteel.com/hellxoul/comments/414771.html</wfw:comment><comments>http://www.aygfsteel.com/hellxoul/archive/2014/06/15/414771.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/hellxoul/comments/commentRss/414771.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/hellxoul/services/trackbacks/414771.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.200000762939453px; background-color: #ffffff;"><span style="font-size: medium;">转自Q?/span><span style="font-family: verdana, 'courier new'; line-height: 21px;">http://singo107.iteye.com/blog/1175084</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.200000762939453px; background-color: #ffffff;"><span style="font-size: medium;">数据库事务的隔离U别?个,׃到高依次为Read uncommitted 、Read committed 、Repeatable read 、Serializable Q这四个U别可以逐个解决脏读 、不可重复读 、?nbsp;q几c问题?/span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.200000762939453px; background-color: #ffffff;"><span style="font-size: medium;"><br /></span></p><div style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.200000762939453px; background-color: #ffffff;"><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">√: 可能出现    ×: 不会(x)出现</span></p><table width="90%" cellspacing="0" border="1" cellpadding="4"><tbody><tr><td style="font-size: 1em;"></td><td style="font-size: 1em;"><span style="font-size: medium;">脏读</span></td><td style="font-size: 1em;"><span style="font-size: medium;">不可重复?/span></td><td style="font-size: 1em;"><span style="font-size: medium;">q读</span></td></tr><tr><td style="font-size: 1em;"><span style="font-size: medium;">Read uncommitted</span></td><td style="font-size: 1em;"><span style="font-size: medium;">√</span></td><td style="font-size: 1em;"><span style="font-size: medium;">√</span></td><td style="font-size: 1em;"><span style="font-size: medium;">√</span></td></tr><tr><td style="font-size: 1em;"><span style="font-size: medium;">Read committed</span></td><td style="font-size: 1em;"><span style="font-size: medium;">×</span></td><td style="font-size: 1em;"><span style="font-size: medium;">√</span></td><td style="font-size: 1em;"><span style="font-size: medium;">√</span></td></tr><tr><td style="font-size: 1em;"><span style="font-size: medium;">Repeatable read</span></td><td style="font-size: 1em;"><span style="font-size: medium;">×</span></td><td style="font-size: 1em;"><span style="font-size: medium;">×</span></td><td style="font-size: 1em;"><span style="font-size: medium;">√</span></td></tr><tr><td style="font-size: 1em;"><span style="font-size: medium;">Serializable</span></td><td style="font-size: 1em;"><span style="font-size: medium;">×</span></td><td style="font-size: 1em;"><span style="font-size: medium;">×</span></td><td style="font-size: 1em;"><span style="font-size: medium;">×</span></td></tr></tbody></table><p style="margin: 0px; padding: 0px;"> </p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">注意Q我们讨论隔ȝ别的场景Q主要是在多个事务ƈ?nbsp;的情况下Q因此,接下来的讲解都围l事务ƈ发?/span></p><h5><span style="color: #008000; font-size: medium;">Read uncommitted L提交</span></h5><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">公司发工资了Q领导把5000元打到singo的̎号上Q但是该事务q未提交Q而singo正好L看̎P发现工资已经到̎Q是5000元整Q非帔R 兴。可是不q的是,领导发现发给singo的工资金额不对,?000元,于是q速回滚了事务Q修攚w额后Q将事务提交Q最后singo实际的工资只?2000元,singoI欢喜一场?/span></p><p style="margin: 0px; padding: 0px;"><br /><img src="http://dl.iteye.com/upload/attachment/556524/f244ae46-c8f4-3bc1-906e-d1d9c1af3516.gif" alt="" style="border: 0px;" /></p><p style="margin: 0px; padding: 0px;"> </p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">出现上述情况Q即我们所说的脏读 Q两个ƈ发的事务Q?#8220;事务AQ领导给singo发工?#8221;?#8220;事务BQsingo查询工资账户”Q事务Bd了事务A未提交的数据?/span></p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">当隔ȝ别设|ؓ(f)Read uncommitted Ӟ可能出现脏读,如何避免脏读Q请看下一个隔ȝ别?/span></p><h5><span style="color: #008000; font-size: medium;">Read committed L?/span></h5><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">singo拿着工资卡去消费Q系l读取到卡里实?000元,而此时她的老婆也正好在|上转̎Q把singo工资卡的2000元{到另一账户Qƈ?singo之前提交了事务,当singo扣款Ӟpȝ查到singo的工资卡已经没有钱,扣款p|Qsingo十分U闷Q明明卡里有钱,??.....</span></p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">出现上述情况Q即我们所说的不可重复?nbsp;Q两个ƈ发的事务Q?#8220;事务AQsingo消费”?#8220;事务BQsingo的老婆|上转̎”Q事务A事先d了数据,事务B紧接了更C数据Qƈ提交了事务,而事务A再次d该数据时Q数据已l发生了改变?/span></p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">当隔ȝ别设|ؓ(f)Read committed Ӟ避免了脏读,但是可能?x)造成不可重复诅R?/span></p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">大多数数据库的默认别就是Read committedQ比如Sql Server , Oracle。如何解决不可重复读q一问题Q请看下一个隔ȝ别?/span></p><h5><span style="color: #008000; font-size: medium;">Repeatable read 重复?/span></h5><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">当隔ȝ别设|ؓ(f)Repeatable read Ӟ可以避免不可重复诅R当singo拿着工资卡去消费Ӟ一旦系l开始读取工资卡信息Q即事务开始)Qsingo的老婆׃可能对该记录q行修改Q也是singo的老婆不能在此时{账?/span></p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">虽然Repeatable read避免了不可重复读Q但q有可能出现q读 ?/span></p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">singo的老婆工作在银行部门,Ҏ(gu)帔R过银行内部pȝ查看singo的信用卡消费记录。有一天,Ҏ(gu)在查询到singo当月信用卡的L贚w?Qselect sum(amount) from transaction where month = 本月Qؓ(f)80元,而singo此时正好在外面胡吃v塞后在收银台买单Q消?000元,x增了一?000元的消费记录Qinsert transaction ... Q,q提交了事务Q随后singo的老婆singo当月信用卡消费的明细打印到A4U怸Q却发现消费总额?080元,singo的老婆很诧异,以ؓ(f)?Cq觉Qdq样产生了?/span></p><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">注:(x)Mysql的默认隔ȝ别就是Repeatable read?/span></p><h5><span style="color: #008000; font-size: medium;">Serializable 序列?/span></h5><p style="margin: 0px; padding: 0px;"><span style="font-size: medium;">Serializable 是最高的事务隔离U别Q同时代价也p最高,性能很低Q一般很用,在该U别下,事务序执行Q不仅可以避免脏诅R不可重复读Q还避免了像读?/span></p></div><img src ="http://www.aygfsteel.com/hellxoul/aggbug/414771.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/hellxoul/" target="_blank">hellxoul</a> 2014-06-15 15:15 <a href="http://www.aygfsteel.com/hellxoul/archive/2014/06/15/414771.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>h是如何做代码审查?/title><link>http://www.aygfsteel.com/hellxoul/archive/2014/06/06/414456.html</link><dc:creator>hellxoul</dc:creator><author>hellxoul</author><pubDate>Fri, 06 Jun 2014 02:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/hellxoul/archive/2014/06/06/414456.html</guid><wfw:comment>http://www.aygfsteel.com/hellxoul/comments/414456.html</wfw:comment><comments>http://www.aygfsteel.com/hellxoul/archive/2014/06/06/414456.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/hellxoul/comments/commentRss/414456.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/hellxoul/services/trackbacks/414456.html</trackback:ping><description><![CDATA[<span style="color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; line-height: 27.200000762939453px; background-color: #f7f7f7;">在上一文章中提到q,我已l不在Google工作了。我q没有想清楚应该d?#8212;有两三个非常好的工作Z(x)摆在我面前。因为在q段做决定时间里Q我不再受雇于Q何hQ我惛_以写一些专业性的东西Q?/span><span style="color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; line-height: 27.200000762939453px; background-color: #f7f7f7;">一些很有趣Q但也会(x)在同事和理工作中导致关pȝ张的东西?/span><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;"></p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">Google是一个非怼U的公司。他们做Z很多令hU赞的东?#8212;既是公司外部Qh们可以看到的东西Q也是公司内部。有一些在公司内部q不属于保密的事情,在外部ƈ没有l予_q泛的讨论。这是我今天要说的?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">让Google的程序如此优U的一个最重要的事情看h是非常的单:(x)代码审查。ƈ不是只有Google做这个事?#8212;代码审查已经被广泛的认可ZU非常好的做法,很多人都在这样做。但我还没有看到W二家这样大的公司能把这U事情运用的如此普遍。在GoogleQ?strong style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; background: transparent;">没有E序</strong>QQ何品、Q何项目的E序代码Q可以在没有l过有效的代码审查前提交C码库里的?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;"><strong style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; background: transparent;">所有h</strong>都要l过代码审查。ƈ且很正规的:(x)q种事情应该成ؓ(f)M重要的Y件开发工作中一个基本制度。ƈ不单指品程?#8212;—所有东ѝ它不需要很多的工作Q但它的效果是巨大的?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">从代码审查里能得C么?</p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">很显Ӟ(x)在代码提交前Q用W二眼睛检查一遍,防止bug混入。这是对其最常见的理解,是对代码审查的好处的最q泛的认识。但是,依我的经验来看,q反倒是?strong style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; background: transparent;">最不重?/strong>的一炏Vh们确实在代码审查中找Cbug。可是,q些在代码审查中能发现的l大部分bugQ很昄Q都是微不道的bugQ程序的作者花几分钟的旉p发现它们。真正需要花旉d现的bug不是在代码审查里能找到的?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">代码审查的最大的功用是纯C会(x)性的。如果你在编E,而且<strong style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; background: transparent;">知道</strong>会(x)有同事检查你的代码,你编E态度完全不一样了。你写出的代码将更加整洁Q有更好的注释,更好的程序结?#8212;—因ؓ(f)?strong style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; background: transparent;">知道</strong>Q那个你很在意的人将?x)查看你的程序。没有代码审查,你知道h们最l还是会(x)看你的程序。但q种事情不是立即发生的事Q它不会(x)l你带来同等的紧q感Q它不会(x)l你相同的个判的那种感受?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">q有一个非帔R要的好处。代码审查能<strong style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; background: transparent;">传播知识</strong>。在很多的开发团队里Q经常每一个h负责一个核心模块,每个人都只关注他自己的那个模块。除非是同事的模块媄响了自己的程序,他们从不怺交流。这U情늚后果是,每个模块只有一个h熟?zhn)里面的代码。如果这个h休假?#8212;—但愿不是——辞职了,其他人则束手无策。通过代码审查Q至会(x)有两个h熟?zhn)q些E序——作者,以及(qing)审查者。审查者ƈ不能像程序的作者一样对E序十分了解——但他?x)熟?zhn)程序的设计和架构,q是极其重要的?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">当然Q没有什么事情能单的做下来的。依我的l验Q在你能正确的进行代码审查前Q你需要花旉ȝ学习(fn)。我发现Z在代码审查时l常?x)犯一些错误,D不少ȝ——其在一些缺乏经验的审查者中l常的出玎ͼ他们l了Z一个很遭的代码审查的体验,成ؓ(f)了h们接受代码审查制度的一个障?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">最重要的一个原则:(x)代码审查用意是在代码提交前找到其中的问题——你要发现是它?strong style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; background: transparent;">正确</strong>。在代码审查中最常犯的错?#8212;—几乎每个新手都会(x)犯的错误——是,审查者根据自q~程?fn)惯来评判别人的代码?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">对于一个问题,通常我们能找出十几种Ҏ(gu)去解冟뀂对于一U解x案,我们能有百万U编码方案来实现它。作Z个审查者,你的d不是来确保被审查的代码都采用的是你的~码风格——因ؓ(f)它不可能跟你写的一栗作ZD代码的审查者的d是确保由作者自己写出的代码是正的。一旦这个原则被打破Q你最l将?x)倍感折磨Q深受挫?#8212;—q可不是我们惌的结果?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">问题在于Q这U错误是如此的普遍而易犯。如果你是个E序员,当你遇到一个问题,你能惛_一U解x?#8212;—你就把你惛_的方案作为标准答案。但事情不是q样?#8212;—作ؓ(f)一个好的审查者,你需要明白这个道理?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">代码审查的第二个易犯的毛病是Qh们觉得有压力Q感觉非要说点什么才好。你知道作者用了大量的旉和精力来实现q些E序——不该说点什么吗Q?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">不,你不需要?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">只说一?#8220;哇,不错呀”QQ何时候都不会(x)不合适。如果你L力图扑և一点什么东西来批评Q你q样做的l果只会(x)损害自己的威望。当你不厌其烦的扑և一些东西来Q只是ؓ(f)了说些什么,被审查h׃(x)知道Q你说这些话只是Z填补寂静。你的评论将不再被h重视?/p><p style="border: 0px; margin: 0px 0px 24px; padding: 0px; vertical-align: baseline; line-height: 1.8em; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; background: #f7f7f7;">W三是速度。你不能匆匆忙忙的进行一ơ代码审?#8212;—但你也要能迅速的完成。你的同伴在{你。如果你和你的同事ƈ不想花太多时间进行代码复查,你们很快的完成,那被审查者会(x)觉得很沮丧,q种代码审查带来的只有失望的感觉。就好象是打搅了大家Q大家放下手头的工作来q行审查。事情不该是q样。你q不需要推掉手头上的Q何事情来做代码审查。但如果中途耽误了几个小Ӟ你中间还要休息一?x),喝杯Ӟ冲个澡,或谈会(x)儿闲话。当你回到审查现场,你可以l下去,把事情做完。如果你真是q样Q我x有h愿意在那q等着你?/p><div style="border: 0px; margin: 0px; padding-bottom: 20px; vertical-align: baseline; color: #333333; font-family: 'Microsoft YaHei', 微Y雅黑, Lucida, Verdana, 'Hiragino Sans GB', STHeiti, 'WenQuanYi Micro Hei', SimSun, sans-serif, serif; font-size: 16px; line-height: 27.200000762939453px; background: #f7f7f7;">[英文原文Q?a rel="nofollow" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; color: #018d8e; text-decoration: none; background: transparent;">Things Everyone Should Do: Code Review</a> ]</div><img src ="http://www.aygfsteel.com/hellxoul/aggbug/414456.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/hellxoul/" target="_blank">hellxoul</a> 2014-06-06 10:04 <a href="http://www.aygfsteel.com/hellxoul/archive/2014/06/06/414456.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu 14.04 64位安装wpshttp://www.aygfsteel.com/hellxoul/archive/2014/04/20/412710.htmlhellxoulhellxoulSun, 20 Apr 2014 13:40:00 GMThttp://www.aygfsteel.com/hellxoul/archive/2014/04/20/412710.htmlhttp://www.aygfsteel.com/hellxoul/comments/412710.htmlhttp://www.aygfsteel.com/hellxoul/archive/2014/04/20/412710.html#Feedback0http://www.aygfsteel.com/hellxoul/comments/commentRss/412710.htmlhttp://www.aygfsteel.com/hellxoul/services/trackbacks/412710.html因ؓ(f)已经安装了libfreetype,|上也说64位的安装32位的libfreetype ?x)有问题Q同Ӟ自己pȝ也装不上32位的libfreetype L提示冲突?br />没办法强制安?br />
sudo dpkg -i --force-all --ignore-depends=libfreetype6:i386 --ignore-depends=libfontconfig1:i386 wps-office_8.1.0.3724~b1p2_i386.deb
搞定


hellxoul 2014-04-20 21:40 发表评论
]]>
win8.1 启动条目删除后不能进入系l?修复http://www.aygfsteel.com/hellxoul/archive/2014/04/19/412689.htmlhellxoulhellxoulSat, 19 Apr 2014 12:41:00 GMThttp://www.aygfsteel.com/hellxoul/archive/2014/04/19/412689.htmlhttp://www.aygfsteel.com/hellxoul/comments/412689.htmlhttp://www.aygfsteel.com/hellxoul/archive/2014/04/19/412689.html#Feedback0http://www.aygfsteel.com/hellxoul/comments/commentRss/412689.htmlhttp://www.aygfsteel.com/hellxoul/services/trackbacks/412689.htmlbcdboot h:\windows \s c:
h:为系l启动盘所在的盘符

hellxoul 2014-04-19 20:41 发表评论
]]>
վ֩ģ壺 ¡| | | ˫| | | | | ̨| ƽ| | | | ƽ| Ʊ| | ͨ| | | | ʯʨ| ʯ¥| Ͷ| | | ͬ| | ĩ| | ͨμ| | | | ¡Ң| ɽ| | ˮ| | | ӥ̶| ̩|