锘??xml version="1.0" encoding="utf-8" standalone="yes"?>BlogJava-灏忚彍姣?#23011;涙妧鏈垎浜?/title><link>http://www.67529968.com/caizh2009/</link><description>涓庡瀹跺叡鍚屾垚闀?/description><language>zh-cn</language><lastBuildDate>Mon, 25 Feb 2019 15:23:06 GMT</lastBuildDate><pubDate>Mon, 25 Feb 2019 15:23:06 GMT</pubDate><ttl>60</ttl><item><title>java sax 瑙瀽 瀹炰緥http://www.67529968.com/caizh2009/archive/2011/05/11/350042.html灏忚彍姣?#23011;?/dc:creator>灏忚彍姣?#23011;?/author>Wed, 11 May 2011 14:34:00 GMThttp://www.67529968.com/caizh2009/archive/2011/05/11/350042.htmlhttp://www.67529968.com/caizh2009/comments/350042.htmlhttp://www.67529968.com/caizh2009/archive/2011/05/11/350042.html#Feedback0http://www.67529968.com/caizh2009/comments/commentRss/350042.htmlhttp://www.67529968.com/caizh2009/services/trackbacks/350042.html 
鐢?/strong>SAX瑙瀽XML瀹炰緥
瀹炰緥锛氫互涓嬭緭鍑?/strong>涓殑鎵鏈夊睘鎬?#37724;屾?#22249;鍊?/strong>
package com.meixin.xml;

import java.io.File;
import java.util.HashMap;
import java.util.Vector;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

public class PraseXML extends DefaultHandler
{

  private Vector<String> tagName;

  private Vector<String> tagValue;

  private int step;

  // 寮濮?#29785;瀽XML鏂囦欢
  public void startDocument() throws SAXException
  {
    tagName = new Vector<String>();
    tagValue = new Vector<String>();
    step = 0;
  }

  // 缁撴潫瑙瀽XML鏂囦欢
  public void endDocument() throws SAXException
  {
    for (int i = 0; i < tagName.size(); i++)
    {
      if (!tagName.get(i).equals("") || tagName.get(i) != null)
      {
        System.out.println("鑺傜偣鍚嶇锛? + tagName.get(i));
        System.out.println("鑺傜偣鍊?#38171;? + tagValue.get(i));
      }
    }
  }

  /**
    * 鍦?#29785;?#38322;婂埌涓涓?#23534;濮嬪厓绱犳椂?#32048;?#30367;鐢?#23005;?#37826;规硶.浣嗘槸?#32139;?#21395;绱?#37832;?#38322;嶅鏃跺彲?#20114;?#22172;宸卞啓绠楁硶鏉尯?#22414;
    * 杩?#27996;?#38322;嶅?#23943;殑?#21395;绱?qName?#27128;浠涔? <name:page ll=""></name:page>杩?#37837;峰啓灏变細鎶?#37713;篠AXException閿欒
    * 閫氬父鎯?#37712;?#28051;媞Name绛?#27996;localName
    */

  public void startElement(String uri, String localName, String qName,
      Attributes attributes) throws SAXException
  {
    // 鑺傜偣鍚嶇
    tagName.add(qName);
    // 寰幆?#32237;鍑哄睘鎬?
    for (int i = 0; i < attributes.getLength(); i++)
    {
      // 鑾峰彇?#30552;鎬?#37722;嶇
      System.out.println("?#30552;鎬?#37722;嶇锛? + attributes.getQName(i));
      // 鑾峰彇?#30552;鎬?#37706;?
      System.out.println("?#30552;鎬?#37706;?#38171;?
          + attributes.getValue(attributes.getQName(i)));
    }

  }

  /**
    * 鍦亣?#22476;缁撴潫鏍囩?#28844;椂?#30367;鐢?#23005;?#37826;规硶
    */

  public void endElement(String uri, String localName, String qName)
      throws SAXException
  {

    step = step + 1;
  }

  /**
    * 璇诲彇鏍囩閲岀殑鍊?ch鐢?#37833;?#28699;樻?#28844;?#24879;?#23680;殑xml?#27537;瀛?#32471;暟鎹?鍖呮嫭鏍囩,鍒?#28654;嬪灏忔槸2048,
    * 姣忚閲婂埌鏂扮殑瀛?#32471;細鎶?#28729;冩?#35826;?#29362;埌char[]閲屻?nbsp;   * 娉剰,杩?#28051;char瀛?#32471;細?#22172;宸?#32480;?#37918;?#28699;?#37708;殑瀛?#32471;?
    * 骞?#28051;嶆槸姣?#28051;琛?#28751;变細鍒?#37826;?#28051;娆char,start,length?#27128;鐢xml?#27537;?#21395;绱犳暟鎹?#32429;?#28729;氱殑,
    * 鏆傛椂鎵?#28051;嶅埌瑙勫緥,?#20114;鍚?#37930;嬫簮浠爜.
    *    
    * 杩?#38322;?#28051;涓?#23005;?#37837;囩锛屽弽鏍囩閮戒細琚?#37813;?#29723;?#28051;娆characters锛屾墍?#20114;鍦弽鏍囩?#28844;椂涓?#37922;?#38014;?#23536;?#37711;?#28051;殑鍊?
    */

  public void characters(char ch[], int start, int length)
      throws SAXException
  {
    // 鍙?#29781;佸綋鍓嶇殑鏍囩缁勭殑闀?#25652;?#28051;鑷?#38171;?#37706;?#28751;?#28051;嶈祴锛?#37714;欏弽鏍囩涓?#29722;?#29825;?#37714;?#37734;?#37712;?
    if (tagName.size() - 1 == tagValue.size())
    {
      tagValue.add(new String(ch, start, length));
    }
  }

  public static void main(String[] args)
  {
    String filename = "MyXml.xml";
    SAXParserFactory spf = SAXParserFactory.newInstance();
    try
    {
      SAXParser saxParser = spf.newSAXParser();
      saxParser.parse(new File(filename), new PraseXML());
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }

  public Vector getTagName()
  {
    return tagName;
  }

  public void setTagName(Vector tagName)
  {
    this.tagName = tagName;
  }

  public Vector getTagValue()
  {
    return tagValue;
  }

  public void setTagValue(Vector tagValue)
  {
    this.tagValue = tagValue;
  }

}
?#32237;鍑?#32513;?#37835;?#38171;?/span>
?#30552;鎬?#37722;嶇锛歱ersonid
?#30552;鎬?#37706;?#38171;歟01
?#30552;鎬?#37722;嶇锛歟nable
?#30552;鎬?#37706;?#38171;歵rue
?#30552;鎬?#37722;嶇锛歱ersonid
?#30552;鎬?#37706;?#38171;歟02
?#30552;鎬?#37722;嶇锛歟nable
?#30552;鎬?#37706;?#38171;false
?#30552;鎬?#37722;嶇锛歱ersonid
?#30552;鎬?#37706;?#38171;歟03
?#30552;鎬?#37722;嶇锛歟nable
?#30552;鎬?#37706;?#38171;歵rue
鑺傜偣鍚嶇锛歱eople
鑺傜偣鍊?#38171;?

    
鑺傜偣鍚嶇锛歱erson
鑺傜偣鍊?#38171;?
    
鑺傜偣鍚嶇锛歯ame
鑺傜偣鍊?#38171;?#23534;?#28051;?
鑺傜偣鍚嶇锛歵el
鑺傜偣鍊?#38171;?128
鑺傜偣鍚嶇锛歟mail
鑺傜偣鍊?#38171;歵xq512@sina.com
鑺傜偣鍚嶇锛歱erson
鑺傜偣鍊?#38171;?
    
鑺傜偣鍚嶇锛歯ame
鑺傜偣鍊?#38171;meixin
鑺傜偣鍚嶇锛歵el
鑺傜偣鍊?#38171;?252525
鑺傜偣鍚嶇锛歟mail
鑺傜偣鍊?#38171;wnight88@sina.com
鑺傜偣鍚嶇锛歱erson
鑺傜偣鍊?#38171;?
    
鑺傜偣鍚嶇锛歯ame
鑺傜偣鍊?#38171;yu
鑺傜偣鍚嶇锛歵el
鑺傜偣鍊?#38171;?389654
鑺傜偣鍚嶇锛歟mail
鑺傜偣鍊?#38171;yu@188.net
鏂囦?#36346;唴瀹?/span>
<?xml version="1.0" encoding="UTF-8"?>
<people>

  <person personid="e01" enable="true">
    <name>寮?#28051;?font color="#0000ff"></name>
    <tel>5128</tel>
    <email>txq512@sina.com</email>
  </person>
    
  <person personid="e02" enable="false">
    <name>meixin</name>
    <tel>5252525</tel>
    <email>wnight88@sina.com</email>
  </person>
    
  <person personid="e03" enable="true">
    <name>yu</name>
    <tel>5389654</tel>
    <email>yu@188.net</email>
  </person>
    
</people>

http://wnight88.blog.51cto.com/512204/163197/


]]>
Spring 妗?#37835;剁殑璁?#29825;?#37918;嗗康涓?#29825;?#29825;?#22959;?#23534;忓垎?#28733;http://www.67529968.com/caizh2009/archive/2011/02/15/344368.html灏忚彍姣?#23011;?/dc:creator>灏忚彍姣?#23011;?/author>Tue, 15 Feb 2011 08:13:00 GMThttp://www.67529968.com/caizh2009/archive/2011/02/15/344368.htmlhttp://www.67529968.com/caizh2009/comments/344368.htmlhttp://www.67529968.com/caizh2009/archive/2011/02/15/344368.html#Feedback0http://www.67529968.com/caizh2009/comments/commentRss/344368.htmlhttp://www.67529968.com/caizh2009/services/trackbacks/344368.html

绠浠?#38171;?/strong> Spring 浣?#28051;?#37916;?#37734;?#37832;浼?#32457;?#27537;妗?#37835;?#28052;?#28051;锛?#23480;?#29722;?#39582;?#23049;涚殑浣?#37922;?#38171;?#39582;?#28051;?#37832;夊緢澶氬鍏跺垎?#28733;?#27537;鏂囩?#29358;?#37832;?#37826;?#28751;?#28000;庡彟澶?#28051;涓?#29785;?#29785;?#29831;?#37733;惧墫?#28733;鍑?Spring 妗?#37835;剁殑浣?#38000;?#29825;?#29825;?Spring 妗?#37835;剁殑楠?#26976;?#37835;?#37835;勭殑璁?#29825;?#37918;嗗康锛?#37832;?#38317;?#37713;?#28051;?#37837;?#36423;?#32513;勪欢锛?#28051;?#28000;涔堥渶瑕?#26473;?#27996;?#32513;勪欢锛?#28729;?#28000;?#37721;堟槸濡?#28003;?#32513;?#37722;?#37734;?#28051;璧?#37835;勬垚 Spring ?#27537;楠?#26976;?#37835;?#37835;?#38171;?Spring ?#27537; AOP 鐗?#37804;?#37721;堟槸濡?#28003;?#37714;?#37922;?#26473;?#27996;涘熀纭?#27537;楠?#26976;?#37835;?#37835;?#37833;?#23480;?#28003;滅殑锛?Spring 涓?#37721;?#28003;?#37922;?#27996;?#38317;?#27996;?#29825;?#29825;?#22959;?#23534;?#37833;?#28729;屾垚瀹冪殑杩?#32457;嶈璁殑锛?#28729;冪殑杩?#32457;嶈璁?#37918;嗗康瀵?#28725;规垜浠互鍚庣殑?#33931;?#27426;璁?#29825;?#37832;?#28003;?#37722;?#32448;?#38171;?#37832;?#37826;?#28751;?#29831;?#32513;?#29785;?#32475;?#26473;?#27996;涢棶棰樸?/p>

Spring ?#27537;楠?#26976;?#37835;?#37835;?/strong>

Spring 鎬诲叡鏈夊崄鍑?#28051;?#32513;勪欢锛?#28003;嗘槸鐪熸鏍?#36423;冪殑缁?#28000;跺彧鏈?#37713;?#28051;?#38171;?#28051;?#38344;槸 Spring 妗?#37835;剁殑鎬讳綋鏋?#37835;勫浘锛?/p>
鍥?1 .Spring 妗?#37835;剁殑鎬讳綋鏋?#37835;勫浘
鍥?1 .Spring 妗?#37835;剁殑鎬讳綋鏋?#37835;勫浘

浠?#28051;婂浘涓彲?#20114;鐪?#37713;?Spring 妗?#37835;?#28051;殑鏍?#36423;?#32513;?#28000;跺彧鏈?#28051;?#28051;?#38171;欳ore銆丆ontext ?#25328; Beans銆?#28729;?#28000;?#37835;勫缓璧?#27996;嗘暣涓?Spring ?#27537;楠?#26976;?#37835;?#37835;?#37510;傛病鏈?#28729;?#28000;?#28751;?#28051;嶅彲鑳?#37832;?AOP銆乄eb 绛?#28051;婂?#20636;殑鐗?#37804;?#37716;?#38003;?#37510;?#28051;?#38344;?#28052;?#28751;?#28051;?#29781;?#28000;?#26473;?#28051;?#28051;?#32513;?#28000;跺叆鎵嬪垎?#28733; Spring銆?/p>

Spring ?#27537;璁?#29825;?#37918;嗗康

?#22688;闈?#28000;?#32513;?#27996;?Spring ?#27537;涓?#28051;?#37837;?#36423;?#32513;勪欢锛屽鏋?#37712;?#37734;?#28729;?#28000;?#28051;?#28051;?#28051;?#38315;?#37713;?#37837;?#36423;冪殑璇?#38171;?#38317;?#28751;?#38344;?Beans 缁勪欢鑾睘浜?#38171;?#28051;?#28003;?#26473;?#37837;?#29831;?#38171;屽叾瀹?Spring 灏辨槸闈?#37722;?Bean ?#27537;?#32042;绋?#38171;BOP,Bean Oriented Programming锛?#38171;孊ean 鍦?Spring 涓?#37813;嶆槸鐪熸?#27537;涓?#29785;?#37510;?/p>

Bean 鍦?Spring 涓?#28003;?#37922;?#28751;卞儚 Object 瀵?OOP ?#27537;?#21104;涔?#28051;鏍?#38171;屾病鏈夊?#30789;薄?#27537;姒?#36423;?#28751;卞?#24532;病鏈?#38344;?#37722;?#28725;硅薄?#32042;绋?#38171;孲pring 涓病鏈? Bean 涔?#28751;辨病鏈?Spring 瀛?#37734;殑?#21104;涔?#37510;?#28751;卞儚涓娆紨鍑鸿垶鍙?#38318;?#37713;?#28598;囧浜?#28003;嗘槸鍗存病鏈夋紨鍛?#28051;鏍?#37510;?#28051;?#28000;涔?#29781;?Bean 杩?#32457;?#29785;掕壊 Bean 鎴?#38000;?#28051;?#28003;?#37734;? Spring 濡?#23005;?#38322;嶈锛?#26473;?#37922;?Spring 妗?#37835;剁殑璁?#29825;洰鏍?#37712;?#28729;?#38171;孲pring 涓?#28003;?#28641;?#23005;?#23092;?#29723;?#38171;屾垜浠?#37922;?Spring ?#27537;?#24107;鍥犳槸浠涔?#38171;屾兂鎯?#28003;犱細鍙?#37916;板師鏉? Spring 瑙?#37712;?#27996;?#28051;涓?#38344;炲父鍏?#38335;殑?#26870;棰?#28000;栧彲?#20114;璁?#28003;?#37814;婂?#30789;薄涔?#38338;寸殑?#32247;璧?#37711;?#32495;昏浆鑰?#37922;?#38320;嶇疆鏂囦欢鏉?#32480;?#37918;?#38171;?#28052;?#28751;辨槸浠栫殑?#32247;璧?#23049;?#37711;?#37832;?#37714;?#37510;?#38000;?#26473;?#28051;?#23049;?#37711;?#37711;?#32495;?#37734;?#28051;涓?#37721;? Ioc 瀹瑰櫒涓?#32480;?#37918;?#38171;?#38317;?Ioc 瀹瑰櫒涓?#37832;夊?#22559;槸浠涔?#28751;辨槸琚?Bean 鍖呰?#22317;殑瀵硅薄銆係pring 姝槸閫氳繃鎶婂?#30789;薄鍖呰鍦?Bean 涓?#38000;?#26440;惧埌瀵?#26473;?#27996;?#28725;硅薄绠?#37918;嗕互鍙?#28051;浜?#37714;?#26864;濆?#26664;搷浣滅殑?#27952;?#27537;銆?/p>

瀹?#26473;?#32457;嶈璁?#32475;?#37923;?#28729;屽叏?#34987;浼?#27996;?Java 瀹?#37916;?OOP ?#27537;璁?#29825;?#37918;嗗康锛屽綋?#21159;浜?Java 鏈韩?#27537;璁?#29825;?#29781;?#23011;?Spring 澶?#37833;?#28598;?#28598;氬澶?#38171;?#28003;嗘槸閮芥槸鏋勫缓涓涓暟鎹?#32513;?#37835;?#38171;岀?#36346;悗鏍规嵁杩?#28051;暟鎹?#32513;?#37835;勮璁?#28000;栫殑鐢?#28699;樼幆澧?#38171;?#39582;?#29825;?#28729;?#37734;?#26473;?#28051;幆澧?#28051;?#37816;夌収涓瀹氱殑瑙勫緥鍦?#28051;嶅?#28357;殑杩?#37716;?#38171;?#37734;?#28729;?#28000;殑涓嶅杩?#37716;?#28051;?#29825;? 璁?#28051;绯?#37714;?#28051;庣幆澧冩垨鑰?#28051;庡叾浠?#28051;綋瀹屾垚淇伅浜?#37817;?#37510;?#26473;?#37837;?#37807;?#37833;?#37733;?#26473;?#28598;?#37807;?#37807;?#37812;?#28000;?#37922;埌?#27537;鍏?#28000;?#22935;?#37835;?#38318;芥槸澶?#37809;被浼肩殑璁?#29825;?#37918;嗗康銆?/p>

鏍?#36423;?#32513;?#28000;跺浣曞鍚?#23480;?#28003;?/strong>

?#22688;闈?#29831;?Bean ?#27128; Spring 涓?#37711;?#38335;?#37733;?#32497;?#38171;?#38317;?Context ?#25328; Core 鍙?#37832;?#28003;?#28003;?#37922;?#37723;?#38171;熷墠闈?#37722;?Bean 姣?#28003;?#28051;鍦烘紨鍑?#28051;殑?#32040;鍛樼殑璇?#38171;?#38317;?Context 灏辨槸杩?#37734;烘紨鍑虹殑?#22454;鍙拌?#23678;锛?#38000;?Core 搴?#29831;?#28751;辨槸?#32040;鍑虹殑閬撳叿浜?#37510;?#37721;?#37832;?#28000;?#28000;?#37734;?#28051;璧?#37813;嶈兘鍏峰鑳芥紨鍑?#28051;鍦?#28610;?#37812;忕殑鏈?#29056;鏈殑鏉欢銆傚綋?#21159;鏈?#37832;?#29056;鏈殑鏉欢杩?#28051;嶈兘浣?#26473;?#37734;烘紨鍑鸿劚棰?#38000;?#37713;?#38171;?#26473;?#29781;?#28000;?#29723;紨?#27537;鑺傜洰?#20923;澶熺殑绮? 褰?#38171;?#26473;?#27996;?#38010;傜洰灏辨槸 Spring 鑳芥彁渚涚殑鐗硅壊鍔?#38003;?#27996;?#37510;?/p>

鎴?#28000;?#37933;亾 Bean 鍖呰?#21615;殑?#27128; Object锛?#38000;?Object 蹇呯劧鏈夋暟鎹?#38171;屽浣?#32513;?#26473;?#27996;涙暟鎹彁渚?#37922;?#28699;樼幆澧?#28751;辨槸 Context 瑕?#29785;?#37712;崇殑?#26870;棰?#38171;屽 Context 鏉?#29831;?#28000;?#28751;辨槸瑕?#37721;?#37916;?#23011;?#28051;?Bean 涔?#38338;寸殑鍏?#32495;?#38171;?#28051;?#28729;?#28000;?#23524;?#32468;嬭繖绉嶅叧绯?#39582;?#28051;?#29781;?#32513;?#37814;?#28610;?#26473;?#32457;嶅叧绯?#37510;?#37813;?#20114; Context 灏辨槸涓涓?Bean 鍏?#32495;荤殑?#27878;鍚?#38171;?#26473;?#28051;?#37711;?#32495;婚泦鍚?#37721;?#37721;?Ioc 瀹瑰櫒锛?#28051;鏃?#23524;?#32468;嬭捣杩?#28051;?Ioc 瀹瑰櫒鍚?Spring 灏卞彲?#20114;涓?#28003;?#23480;?#28003;?#27996;?#37510;?#38317;?Core 缁?#28000;跺張鏈?#28000;涔?#37922;?#23005;?#28052;?#37734;板憿锛?#37711;?#28729;?Core 灏辨槸鍙?#37916;?#37510;?#23524;?#32468;嬪拰缁?#37814;?#23011;?#28051;?Bean 涔?#38338;寸殑鍏?#32495;?#37813;?#28214;瑕佺殑涓浜?#37714;楃殑宸?#37711;?#38171;?#28000;?#26473;?#28051;?#29785;?#25652;?#37930;?#37833;?#38171;孋ore 杩?#28051;?#32513;?#28000;跺彨 Util 鏇?#38003;?#29825;?#28003;?#37918;?#29785;?#37510;?/p>

瀹?#28000;?#28052;?#38338;村彲?#20114;鐢?#28051;嬪浘鏉?#29723;?#32448;?#38171;?/p>
鍥?2. 涓?#28051;?#32513;?#28000;跺叧绯?/font>
鍥?2. 涓?#28051;?#32513;?#28000;跺叧绯? src=

鏍?#36423;?#32513;勪欢璇?#29785;?/strong>

杩?#38322;?#28751;?#29831;?#32513;?#28000;?#32513;?#23011;?#28051;?#32513;?#28000;跺唴閮被?#27537;灞?#23046;?#37711;?#32495;?#38171;屼互鍙?#28729;?#28000;?#37734;?#26473;愯?#23678;椂?#27537;鏃跺?#24539;搴?#37510;傛垜浠?#37734;?#28003;?#37922;?Spring ?#27128;搴?#29831;?#23049;剰?#27537;鍦?#37826;?#37510;?/p>

Bean 缁勪欢

?#22688;闈?#23480;?#32513;忚鏄?#27996;?Bean 缁?#28000;跺 Spring ?#27537;閲嶈鎬?#38171;?#28051;?#38344;?#37930;?#37930;?Bean 杩?#28051;?#32513;?#28000;跺紡鎬?#28052;?#29825;?#29825;殑銆侭ean 缁?#28000;跺湪 Spring ?#27537; org.springframework.beans 鍖?#28051;?#37510;?#26473;?#28051;?#37718;?#28051;嬬殑鎵鏈夌被涓?#29781;?#29785;?#37712;?#27996;?#28051;変欢浜?#38171;欱ean ?#27537;瀹氫箟銆丅ean ?#27537;鍒涘?#36720;互鍙婂 Bean ?#27537;瑙瀽銆?#28725;?Spring ?#27537;浣?#37922;?#38000;?#37833;?#29831;村敮涓?#28214;瑕?#37711;?#36423;冪殑灏辨槸 Bean ?#27537;鍒涘缓锛屽叾浠?#28051;?#28051;?#37922;?Spring 鍦?#37712;?#38318;?#29999;?#28003;?#28729;屾垚浜?#38171;屽浣犳潵璇存槸閫?#37828;庣殑銆?/p>

Spring Bean ?#27537;鍒涘缓鏃跺?#31295;?#23340;殑宸?#37720;傛寮?#38171;?#28000;栫殑椤剁骇鎺?#37721;槸 BeanFactory锛?#28051;嬪?#28844;槸杩?#28051;?#23480;?#37720;傜殑缁?#37813;?#28766;?#23046;?#37711;?#32495;?#38171;?/p>
鍥?4. Bean 宸?#37720;傜殑缁?#37813;?#37711;?#32495;?/font>
鍥?4. Bean 宸?#37720;傜殑缁?#37813;?#37711;?#32495;? src=

BeanFactory 鏈?#28051;?#28051;?#28699;愮被锛ListableBeanFactory銆丠ierarchicalBeanFactory ?#25328; AutowireCapableBeanFactory銆?#28003;嗘槸浠?#28051;婂浘涓?#37812;?#28000;彲?#20114;鍙?#37916;?#37832;缁堢殑榛?#29825;?#28729;?#37916;扮被?#27128; DefaultListableBeanFactory锛?#28000;?#28729;?#37916;?#27996;?#37813;鏈夌殑鎺?#37721;?#37510;?#38317;?#28051;?#28003;?#29781;?#28729;氫箟杩欎箞澶氬眰娆殑鎺?#37721;?#37723;?#38171;熸煡闃?#26473;?#27996;涙帴鍙殑?#31790;?#29212;?#25328;璇?#37828;庡彂鐜?#38171;?#23011;?#28051;?#37818;?#37721;? 閮?#37832;?#28000;?#28003;?#37922;殑鍦?#37722;?#38171;?#28729;?#28051;?#29781;佹槸涓?#27996;嗗尯?#22414;鍦?Spring 鍐?#38318;?#37734;?#37823;?#28003;?#26473;囩涓?#28725;硅薄?#27537;浼?#38315;掑拰?#27974;鍖?#26473;囩涓?#38171;屽瀵硅薄?#27537;?#26271;鎹?#29825;块棶鎵鍋氱殑闄?#37714;?#37510;備緥濡? ListableBeanFactory 鎺?#37721;?#29723;?#32448;?#26473;?#27996;?Bean ?#27128;?#24434;鍒?#29723;殑锛?#38000;?HierarchicalBeanFactory 琛?#32448;虹殑?#27128;杩?#27996;? Bean ?#27128;鏈?#32513;?#37813;?#37711;?#32495;荤殑锛?#28052;?#28751;辨槸姣?#28051;?Bean 鏈夊彲鑳?#37832;夌埗 Bean銆侫utowireCapableBeanFactory 鎺?#37721;?#28729;氫箟 Bean ?#27537;?#22172;鍔?#29761;?#38320;?#29785;?#37714;?#37510;?#26473;欏洓涓?#37818;?#37721;叡鍚?#28729;氫箟浜?Bean ?#27537;?#27878;鍚?#37510;丅ean 涔?#38338;寸殑鍏?#32495;?#37510;佷互鍙?Bean 琛?#28051;?#37510;?/p>

Bean ?#27537;瀹氫箟涓?#29781;?#37832;?BeanDefinition 鎻忚堪锛屽涓嬪浘璇?#37828;?#27996;?#26473;?#27996;涚被?#27537;灞?#23046;?#37711;?#32495;?#38171;?/p>
鍥?5. Bean 瀹氫?#22796;殑?#34987;灞?#23046;?#37711;?#32495;诲浘
鍥?5. Bean 瀹氫?#22796;殑?#34987;灞?#23046;?#37711;?#32495;诲浘

Bean ?#27537;瀹氫箟灏辨槸瀹屾暣?#27537;鎻忚堪浜?#37734;?Spring ?#27537;閰嶇疆鏂囦欢涓?#28003;?#28729;氫?#22796;殑 <bean/> 鑺傜偣涓?#37813;鏈夌殑淇伅锛?#37718;呮嫭鍚?#32457;嶅瓙鑺傜偣銆傚綋 Spring ?#22426;鍔?#29785;瀽浣?#28729;氫?#22796;殑涓涓?<bean/> 鑺傜偣鍚?#38171;?#37734;?Spring ?#27537;鍐?#38318;?#28000;?#28751;?#29722;浆鍖栨垚 BeanDefinition 瀵硅薄銆備互鍚?#37813;鏈夌殑鎿?#28003;?#38318;芥槸瀵?#26473;?#28051;?#28725;硅薄瀹屾垚?#27537;銆?/p>

Bean ?#27537;瑙瀽杩囩闈炲父澶?#37833;?#38171;?#37716;?#38003;?#29722;垎?#27537;寰?#32513;?#38171;屽洜涓?#26473;?#38322;岄渶瑕?#29722;?#37813;?#28766;曠殑鍦?#37826;?#23536;?#28598;?#38171;屽繀椤讳繚璇?#37832;夎冻澶熺殑鐏垫椿鎬?#38171;屼互搴?#28725;瑰彲鑳界殑鍙?#37718;?#37510;侭ean ?#27537;瑙瀽涓?#29781;?#28751;辨槸瀵?Spring 閰嶇疆鏂囦欢?#27537;瑙瀽銆?#26473;?#28051;?#29785;瀽杩囩涓?#29781;?#38315;氳繃涓嬪浘涓殑?#34987;瀹屾垚锛?/p>
鍥?6. Bean ?#27537;瑙瀽?#34987;
鍥?6. Bean ?#27537;瑙瀽?#34987;

?#32139;?#21159;杩?#37832;夊?#34562;綋瀵?tag ?#27537;瑙瀽杩?#38322;?#39582;舵病鏈夊垪鍑?#37510;?/p>

Context 缁勪欢

Context 鍦?Spring ?#27537; org.springframework.context 鍖?#28051;?#38171;屽墠闈?#23480;?#32513;忚瑙?#27996;?Context 缁?#28000;跺湪 Spring 涓殑浣?#37922;?#38171;?#28000;?#28729;?#38340;?#28051;?#28751;辨槸缁?Spring ?#24385;渚?#28051;涓?#26473;愯?#23678;椂?#27537;?#24134;澧?#38171;?#37922;互淇?#28699;?#37722;?#28051;?#28725;硅薄?#27537;?#23032;鎬?#37510;?#28051;?#38344;?#37930;?#28051;涓嬭繖涓幆澧冩槸濡?#28003;?#37835;勫缓?#27537;銆?/p>

ApplicationContext ?#27128; Context ?#27537;椤剁骇鐖剁被锛?#28000;?#38340;?#27996;嗚兘鏍?#29831;?#28051;涓?#25652;?#37922;幆澧冪殑?#29056;鏈?#28103;伅澶?#38171;?#28000;?#26473;?#32513;?#37813;?#27996;?#27996;?#28051;?#37818;?#37721;?#38171;?#26473;?#27996;?#28051;?#37818;?#37721;?#28051;?#29781;佹槸鎵?#28766;?#27996;?Context ?#27537;鍔?#38003;?#37510;?#28051;?#38344;槸 Context ?#27537;?#34987;缁?#37835;勫浘锛?/p>
鍥?7. Context 鐩?#37711;崇殑?#34987;缁?#37835;勫浘
鍥?7. Context 鐩?#37711;崇殑?#34987;缁?#37835;勫浘

锛?#37836;?#37930;?鍥?7 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

浠?#28051;婂浘涓彲?#20114;鐪?#37713;?ApplicationContext 缁?#37813;?#27996;?BeanFactory锛?#26473;欎篃璇?#37828;?#27996;?Spring 瀹瑰櫒涓?#26473;愯?#23680;殑涓讳綋瀵硅薄?#27128; Bean锛屽彟澶?ApplicationContext 缁?#37813;?#27996;?ResourceLoader 鎺?#37721;?#38171;?#28003;?#23536;?ApplicationContext ?#24434;?#20114;璁块棶?#22476;浠?#28003;?#28598;?#38318;?#29863;勬簮锛?#26473;?#28751;?#37734;?Core 涓?#29831;?#32513;?#29831;?#37828;?#37510;?/p>

ApplicationContext ?#27537;瀛愮被涓?#29781;?#37718;?#37722;?#28051;?#28051;?#37826;?#38344;?#38171;?/p>

  1. ConfigurableApplicationContext 琛?#32448;?#29831;?Context ?#27128;?#24434;淇敼?#27537;锛?#28052;?#28751;辨槸鍦?#37835;勫缓 Context 涓?#37922;?#37812;峰彲?#20114;鍔?#37804;佹?#35826;?#29363;?#26662;慨?#25980;宸?#37832;夌殑閰嶇疆淇伅锛?#28729;?#28051;?#38344;?#37721;?#37832;夊涓?#28699;愮被锛屽叾涓?#37832;缁忓父浣?#37922;殑?#27128;?#24434;鏇?#37826;扮殑 Context锛屽嵆 AbstractRefreshableApplicationContext ?#34987;銆?
  2. WebApplicationContext 椤?#37722;?#37804;?#28052;?#38171;?#28751;辨槸涓?web 鍑?#28598;囩殑 Context 浠栧彲?#20114;鐩存帴璁块棶?#22476; ServletContext锛?#38315;氬父鎯?#37712;?#28051;?#38171;?#26473;?#28051;?#37818;?#37721;?#28003;?#37922;殑灏?#37510;?

鍐嶅線涓嬪垎灏辨槸鎸夌収鏋勫缓 Context ?#27537;鏂囦欢绫诲瀷锛屾帴?#28483;灏辨槸璁块棶 Context ?#27537;鏂?#23534;?#37510;?#26473;?#37837;?#28051;?#39559;涓?#39559;鏋勬垚浜?#28729;屾暣?#27537; Context 绛夌骇灞?#23046;?#37510;?/p>

鎬讳綋鏉?#29831;?ApplicationContext 蹇?#26916;?#29781;?#28729;屾垚?#20114;涓?#37713;犱欢浜?#38171;?/p>

  • 鏍?#29831;?#28051;涓?#25652;?#37922;幆澧?
  • 鍒?#37922;?BeanFactory 鍒涘缓 Bean 瀵硅薄
  • 淇?#28699;?#28725;硅薄鍏?#32495;?#29723;?
  • 鑳?#28598;熸崟鑾?#37722;?#32457;?#27996;嬩欢

Context 浣?#28051;?Spring ?#27537; Ioc 瀹瑰櫒锛屽熀鏈?#28051;婃暣鍚?#27996;?Spring ?#27537;澶?#38318;垎鍔?#38003;?#38171;屾垨鑰?#29831;存槸澶?#38318;垎鍔?#38003;界殑?#29056;纭銆?/p>

Core 缁勪欢

Core 缁勪欢浣?#28051;?Spring ?#27537;鏍?#36423;?#32513;勪欢锛?#28000;?#37711;?#28051;?#37718;?#37722;?#27996;?#23536;?#28598;氱殑鍏?#38335;被锛屽叾涓?#28051;涓?#38322;嶈缁勬垚閮垎灏辨槸瀹氫箟浜?#29863;勬簮?#27537;璁块棶鏂?#23534;?#37510;?#26473;?#32457;?#37814;?#37813;鏈?#29863;勬簮閮?#37814;借薄?#22426;涓涓?#37818;?#37721;殑鏂?#23534;?#23536;?#37706;煎緱鍦互鍚庣殑璁?#29825;?#28051;?#37815;?#37833;?#28699;?#28052;犮?#28051;?#38344;?#28751;?#38322;嶈鐪?#28051;涓嬭繖涓?#38318;垎鍦?Spring ?#27537;浣?#37922;?#37510;?/p>

涓嬪?#28844;槸 Resource 鐩?#37711;崇殑?#34987;缁?#37835;勫浘锛?/p>
鍥?8. Resource 鐩?#37711;崇殑?#34987;缁?#37835;勫浘
鍥?8. Resource 鐩?#37711;崇殑?#34987;缁?#37835;勫浘

锛?#37836;?#37930;?鍥?8 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

浠?#28051;婂?#24807;彲?#20114;鐪?#37713;?Resource 鎺?#37721;?#28751;佽浜?#37722;?#32457;嶅彲鑳界殑璧勬簮绫诲瀷锛?#28052;?#28751;辨槸瀵?#28003;?#37922;?#38000;?#37833;?#29831;?#28766;忚斀浜?#37826;囦欢绫诲?#23340;殑涓?#37722;屻?#28725;?#29863;勬簮?#27537;?#24385;渚?#38000;?#37833;?#29831;?#38171;屽浣?#37814;?#29863;勬簮鍖呰?#21616;捣鏉?#27996;?#32513;欏叾浠?#27996;?#37922;?#26473;欎?#29112;槸涓涓棶棰?#38171;屾垜浠?#37930;嬪埌 Resource 鎺?#37721;?#32513;?#37813;?#27996;?InputStreamSource 鎺?#37721;?#38171;?#26473;?#28051;?#37818;?#37721;?#28051;?#37832;?#28051;?getInputStream 鏂规硶锛?#26473;?#37733;炵殑?#27128; InputStream ?#34987;銆?#26473;?#37837;?#37813;鏈夌殑璧勬簮閮?#29722;彲?#20114;閫氳繃 InputStream 杩?#28051;被鏉?#38014;峰彇锛屾墍?#20114;涔?#28766;忚斀浜?#29863;勬簮?#27537;?#24385;渚?#38000;?#37510;?#37721;?#28598;?#26473;?#37832;?#28051;涓棶棰?#28751;辨槸鍔?#26462;?#29863;勬簮?#27537;?#26870;棰?#38171;?#28052;?#28751;辨槸璧勬簮?#27537;鍔?#26462;?#38000;呰缁?#28051;锛?#28000;?#28051;婂浘涓彲?#20114;鐪?#37713;?#26473;?#28051;?#28000;诲?#27128;鐢? ResourceLoader 鎺?#37721;?#28729;屾垚锛?#28000;?#28766;忚斀浜?#37813;鏈夌殑璧勬簮鍔?#26462;?#38000;呯殑宸?#23534;?#38171;屽彧?#28214;瑕?#28729;?#37916;?#26473;?#28051;?#37818;?#37721;?#28751;卞彲?#20114;鍔?#26462;?#37813;鏈夌殑璧勬簮锛?#28000;栫殑榛?#29825;?#28729;?#37916;版槸 DefaultResourceLoader銆?/p>

涓?#38344;?#37930;?#28051;涓?Context ?#25328; Resource ?#27128;濡?#28003;曞缓绔嬪叧绯荤殑锛熼鍏?#37930;?#28051;涓嬩粬浠殑绫诲叧绯诲浘锛?/p>
鍥?9. Context ?#25328; Resource ?#27537;绫诲叧绯诲浘
鍥?9. Context ?#25328; Resource ?#27537;绫诲叧绯诲浘

浠?#28051;婂?#24807;彲?#20114;鐪?#37713;?#38171;孋ontext ?#27128;鎶?#29863;勬簮?#27537;鍔?#26462;?#37510;?#29785;瀽鍜屾?#24538;堪宸?#28003;?#28654;?#37813;?#32513;?#27996;?ResourcePatternResolver ?#34987;鏉?#28729;屾垚锛?#28000;栫?#31295;綋浜?#28051;涓?#37818;?#28598;?#27996;?#38171;?#28000;?#37814;?#29863;勬簮?#27537;鍔?#26462;?#37510;?#29785;瀽?#25328;璧勬簮?#27537;瀹氫?#22795;暣鍚?#37734;?#28051;璧蜂究浜庡叾浠?#32513;勪欢浣?#37922;?#37510;侰ore 缁勪欢涓?#26473;?#37832;夊緢澶氱被浼肩殑鏂?#23534;?#37510;?/p>

Ioc 瀹瑰櫒濡?#28003;?#23480;?#28003;?/strong>

?#22688;闈?#28000;?#32513;?#27996;?Core 缁勪欢銆丅ean 缁?#28000;跺拰 Context 缁勪欢?#27537;缁?#37835;?#28051;庣浉浜?#37711;?#32495;?#38171;?#28051;?#38344;?#26473;?#38322;?#28000;?#28003;?#37922;?#38000;?#29785;?#25652;?#37930;?#28051;涓嬩粬浠槸濡?#28003;?#26473;愯?#23680;殑锛屼互鍙?#37812;?#28000;?#28641;?#28003;?#29825;?Spring 瀹屾垚鍚?#32457;嶅姛鑳?#38171;孲pring ?#22476;搴?#38003;?#37832;?#38317;?#27996;?#37716;?#38003;?#38171;?#26473;?#27996;?#37716;?#38003;芥槸濡?#28003;?#23536;楁潵?#27537;锛?#28051;?#38344;?#28000;?#32513;?#37510;?/p>

濡?#28003;?#37714;涘缓 BeanFactory 宸?#37720;?/strong>

姝?#28641;?#37733;?2 鎻忚?#25198;殑閭?#37837;?#38171;Ioc 瀹瑰櫒瀹?#38340;?#28051;?#28751;辨槸 Context 缁勪欢缁?#37722;?#37711;?#28000;?#28051;?#28051;?#32513;?#28000;跺叡鍚屾?#21227;缓浜?#28051;涓?Bean 鍏?#32495;?#32515;?#38171;屽浣?#37835;勫缓杩?#28051;?#37711;?#32495;?#32515;?#38171;?#37835;勫缓?#27537;鍏?#37721;?#28751;?#37734;?AbstractApplicationContext ?#34987;?#27537; refresh 鏂规硶涓?#37510;?#26473;?#28051;?#37826;规硶?#27537;浠爜濡?#28051;?#38171;?/p>
娓呭崟 1. AbstractApplicationContext.refresh
                        public void refresh() throws BeansException, IllegalStateException {
                        synchronized (this.startupShutdownMonitor) {
                        // Prepare this context for refreshing.
                        prepareRefresh();
                        // Tell the subclass to refresh the internal bean factory.
                        ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();
                        // Prepare the bean factory for use in this context.
                        prepareBeanFactory(beanFactory);
                        try {
                        // Allows post-processing of the bean factory in context subclasses.
                        postProcessBeanFactory(beanFactory);
                        // Invoke factory processors registered as beans in the context.
                        invokeBeanFactoryPostProcessors(beanFactory);
                        // Register bean processors that intercept bean creation.
                        registerBeanPostProcessors(beanFactory);
                        // Initialize message source for this context.
                        initMessageSource();
                        // Initialize event multicaster for this context.
                        initApplicationEventMulticaster();
                        // Initialize other special beans in specific context subclasses.
                        onRefresh();
                        // Check for listener beans and register them.
                        registerListeners();
                        // Instantiate all remaining (non-lazy-init) singletons.
                        finishBeanFactoryInitialization(beanFactory);
                        // Last step: publish corresponding event.
                        finishRefresh();
                        }
                        catch (BeansException ex) {
                        // Destroy already created singletons to avoid dangling resources.
                        destroyBeans();
                        // Reset 'active' flag.
                        cancelRefresh(ex);
                        // Propagate exception to caller.
                        throw ex;
                        }
                        }
                        }
                        

杩?#28051;?#37826;规硶灏辨槸鏋勫?#28888;暣涓?Ioc 瀹瑰櫒杩囩?#23340;殑瀹屾暣?#27537;浠爜锛?#27996;?#29785;?#27996;?#38322;?#38344;殑姣?#28051;琛?#28000;爜?#29056;鏈?#28051;?#28751;?#27996;?#29785;?#28598;?#38318;垎 Spring ?#27537;?#24107;鐞嗗拰鍔?#38003;?#27996;?#37510;?/p>

杩欐浠爜涓?#29781;?#37718;?#37722;?#26473;?#37837;?#37713;?#28051;?#23005;?#26976;?#38171;?/p>

  • 鏋勫缓 BeanFactory锛屼互渚?#27996;?#27996;?#37922;?#37813;?#28214;?#27537;“?#32040;鍛?#8221;
  • 娉?#37712;屽彲鑳芥劅鍏磋叮?#27537;浜嬩欢
  • 鍒涘缓 Bean 瀹炰緥瀵硅薄
  • 瑙?#37721;?#29722;?#37929;?#37722;殑浜嬩欢

涓?#38344;?#28751;?#32513;?#37722;?#28000;爜?#22414;?#28733;杩?#37713;?#28051;?#26473;囩銆?/p>

绗?#27996;?#28051;夊彞灏辨槸鍦?#37714;涘?#21700;拰閰嶇疆 BeanFactory銆?#26473;?#38322;屾槸 refresh 涔?#28751;辨槸鍒?#37826;伴?#23943;疆锛屽墠闈?#28000;?#32513;?#27996;?Context 鏈夊彲鏇?#37826;扮殑瀛愮被锛?#26473;?#38322;屾?#27128;瀹?#37916;?#26473;?#28051;?#37716;?#38003;?#38171;屽綋 BeanFactory 宸?#28699;?#37734;槸灏辨洿鏂?#38171;屽鏋滄病鏈?#28751;?#37826;?#37714;涘缓銆?#28051;?#38344;槸鏇?#37826;?BeanFactory ?#27537;鏂规硶浠爜锛?/p>
娓呭崟 2. AbstractRefreshableApplicationContext. refreshBeanFactory
                        protected final void refreshBeanFactory() throws BeansException {
                        if (hasBeanFactory()) {
                        destroyBeans();
                        closeBeanFactory();
                        }
                        try {
                        DefaultListableBeanFactory beanFactory = createBeanFactory();
                        beanFactory.setSerializationId(getId());
                        customizeBeanFactory(beanFactory);
                        loadBeanDefinitions(beanFactory);
                        synchronized (this.beanFactoryMonitor) {
                        this.beanFactory = beanFactory;
                        }
                        }
                        catch (IOException ex) {
                        throw new ApplicationContextException(
                        "I/O error parsing bean definition source for "
                        + getDisplayName(), ex);
                        }
                        }
                        

杩?#28051;?#37826;规硶瀹?#37916;?#27996;?AbstractApplicationContext ?#27537;鎶借薄鏂规硶 refreshBeanFactory锛?#26473;欐浠爜娓呮?#27697;殑璇?#37828;?#27996;?BeanFactory ?#27537;鍒涘缓杩囩銆?#23049;剰 BeanFactory 瀵硅薄?#27537;绫诲?#23340;殑鍙?#37718;?#38171;屽墠闈?#28000;?#32513;?#27996;?#28000;?#37832;夊緢澶氬瓙?#34987;锛?#37734;?#28000;涔?#37807;?#37712;?#28051;嬩娇鐢?#28051;?#37722;岀殑瀛愮被杩欓潪?#29238;鍏?#38335;?#37510;侭eanFactory ?#27537;?#24107;濮嬪?#30789;薄?#27128; DefaultListableBeanFactory锛?#26473;?#28051;?#38344;炲父鍏?#38335;?#38171;屽洜涓?#28000;?#29825;?#29825;埌鍚?#38344;?#28725;?#26473;?#28051;?#28725;硅薄?#27537;澶?#32457;嶆搷浣?#38171;?#28051;?#38344;?#37930;?#28051;涓嬭繖涓被?#27537;缁?#37813;?#28766;?#23046;?#32491;诲浘锛?/p>
鍥?10. DefaultListableBeanFactory ?#34987;缁?#37813;?#37711;?#32495;诲浘
鍥?10. DefaultListableBeanFactory ?#34987;缁?#37813;?#37711;?#32495;诲浘

锛?#37836;?#37930;?鍥?10 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

浠?#26473;?#28051;?#37733;?#28051;?#37721;?#37916;伴櫎浜?BeanFactory 鐩?#37711;崇殑绫诲锛?#26473;?#37721;?#37916;?#27996;?#28051;?Bean ?#27537; register 鐩?#37711;?#37510;?#26473;?#37734;? refreshBeanFactory 鏂规硶涓?#37832;?#28051;琛?loadBeanDefinitions(beanFactory) 灏?#37813;惧埌绛?#22935;?#38171;?#26473;?#28051;?#37826;规硶灏?#23534;濮嬪姞杞?#37510;?#29785;瀽 Bean ?#27537;瀹氫箟锛?#28052;?#28751;辨槸鎶?#37922;埛瀹氫?#22796;殑?#26271;鎹?#32513;?#37835;勮浆鍖?#28051;?Ioc 瀹瑰櫒涓殑鐗?#28729;氭暟鎹?#32513;?#37835;?#37510;?/p>

杩?#28051;?#26473;囩?#23338;彲?#20114;鐢?#28051;?#38344;?#37827;跺簭鍥?#29785;?#38322;?#38171;?/p>
鍥?11. 鍒涘缓 BeanFactory 鏃跺簭鍥?/font>
鍥?11. 鍒涘缓 BeanFactory 鏃跺簭鍥? src=

锛?#37836;?#37930;?鍥?11 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

Bean ?#27537;瑙瀽?#25328;鐧?#29825;?#23092;?#32459;?#37827;跺簭鍥惧涓?#38171;?/p>
鍥?12. 瑙瀽?#25328;鐧?#29825;?Bean 瀵硅薄鏃跺簭鍥?/font>
鍥?12. 瑙瀽?#25328;鐧?#29825;?Bean 瀵硅薄鏃跺簭鍥? src=

锛?#37836;?#37930;?鍥?12 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

鍒涘缓濂?BeanFactory 鍚?#38171;屾帴涓嬪?#32472;?#35826;姞涓浜?Spring 鏈韩?#28214;瑕佺殑涓浜?#23480;?#37711;风被锛?#26473;?#28051;?#37823;?#28003;?#37734;?AbstractApplicationContext ?#27537; prepareBeanFactory 鏂规硶瀹屾垚銆?/p>

AbstractApplicationContext 涓?#37818;?#28051;?#37833;殑涓?#29723;?#28000;爜瀵?Spring ?#27537;鍔?#38003;?#37813;?#28766;?#37804;?#29863;?#27996;?#38007;?#37711;?#38322;嶈?#20346;殑浣?#37922;?#37510;傚墠涓?#29723;?#28051;?#29781;佹槸璁?#28003;?#37916;?#37734;彲?#20114;瀵?#23480;?#32513;?#37835;勫缓?#27537; BeanFactory ?#27537;閰嶇疆鍋氫慨?#25980;锛?#37722;?#38344;?#28051;琛?#28751;辨槸璁?#28003;犲彲?#20114;瀵逛互鍚庡?#23941;?#28056;缓 Bean ?#27537;瀹炰緥瀵硅薄?#26882;娣诲姞涓浜涜嚜瀹氫?#22796;殑鎿?#28003;?#37510;?#37813;?#20114;浠?#28000;?#38318;芥槸鎵?#28766;?#27996;?Spring ?#27537;鍔?#38003;?#38171;屾墍?#20114;鎴?#28000;?#29781;?#28699;?#28052;?#28003;?#37922;?Spring 蹇?#26916;诲杩?#28051;閮垎鎼炴?#21614;銆?/p>

鍏?#28051;?#37734;?invokeBeanFactoryPostProcessors 鏂规硶涓?#28051;?#29781;佹槸鑾峰彇瀹?#37916;?BeanFactoryPostProcessor 鎺?#37721;殑瀛愮被銆?#39582;?#37813;?#29723;?#28729;冪殑 postProcessBeanFactory 鏂规硶锛?#26473;?#28051;?#37826;规硶?#27537;澹?#37828;庡涓?#38171;?/p>
娓呭崟 3. BeanFactoryPostProcessor.postProcessBeanFactory
                        void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
                        throws BeansException;
                        

瀹冪殑鍙傛暟?#27128; beanFactory锛?#29831;?#37828;庡彲?#20114;瀵?beanFactory 鍋氫慨?#25980;锛?#26473;?#38322;屾敞鎰忚繖涓?beanFactory ?#27128; ConfigurableListableBeanFactory 绫诲?#23340;殑锛?#26473;欎篃鍗?#29831;?#27996;嗗墠闈?#28000;?#32513;嶇殑涓?#37722;?BeanFactory 鎵浣?#37922;殑鍦?#37722;?#28051;?#37722;?#38171;?#26473;?#38322;屽彧鑳芥槸?#24434;閰嶇疆?#27537; BeanFactory锛岄槻姝?#28051;浜涙暟鎹?#29722;?#37922;埛闅忔剰淇敼銆?/p>

registerBeanPostProcessors 鏂规硶涔熸槸?#24434;?#20114;鑾峰彇鐢埛瀹氫?#22796;殑瀹?#37916;?#27996;?BeanPostProcessor 鎺?#37721;殑瀛愮被锛?#39582;?#37813;?#29723;?#37814;?#28729;?#28000;?#23049;?#37712;屽埌 BeanFactory 瀵硅薄涓殑 beanPostProcessors 鍙?#38322;?#28051;?#37510;侭eanPostProcessor 涓?#28601;?#37828;?#27996;?#28051;?#28051;?#37826;规硶锛歱ostProcessBeforeInitialization銆乸ostProcessAfterInitialization ?#22414;鍒?#37922;?#27996;庡湪 Bean 瀵硅薄鍒?#28654;嬪?#26664;椂鎵?#29723;屻傚彲?#20114;鎵?#29723;?#37922;埛?#22172;瀹氫?#22796;殑鎿?#28003;?#37510;?/p>

鍚?#38344;殑鍑?#29723;?#28000;爜?#27128;鍒?#28654;嬪?#26667;洃鍚?#27996;嬩?#36346;拰瀵?#32495;?#32513;熺殑鍏?#28000;栫洃鍚?#38000;呯殑娉?#37712;?#38171;岀洃鍚?#38000;呭繀椤绘槸 ApplicationListener ?#27537;瀛愮被銆?/p>

濡?#28003;?#37714;涘缓 Bean 瀹炰緥骞?#37835;勫缓 Bean ?#27537;鍏?#32495;?#32515;?/strong>

涓?#38344;?#28751;辨槸 Bean ?#27537;瀹炰緥鍖?#28000;爜锛屾槸浠?finishBeanFactoryInitialization 鏂规硶寮濮嬬殑銆?/p>
娓呭崟 4. AbstractApplicationContext.finishBeanFactoryInitialization
                        protected void finishBeanFactoryInitialization(
                        ConfigurableListableBeanFactory beanFactory) {
                        // Stop using the temporary ClassLoader for type matching.
                        beanFactory.setTempClassLoader(null);
                        // Allow for caching all bean definition metadata, not expecting further changes.
                        beanFactory.freezeConfiguration();
                        // Instantiate all remaining (non-lazy-init) singletons.
                        beanFactory.preInstantiateSingletons();
                        }
                        

浠?#28051;?#38344;?#28000;爜涓彲?#20114;鍙?#37916;?Bean ?#27537;瀹炰緥鍖栨槸鍦?BeanFactory 涓?#37721;?#37922;熺殑銆俻reInstantiateSingletons 鏂规硶?#27537;浠爜濡?#28051;?#38171;?/p>
娓呭崟 5. DefaultListableBeanFactory.preInstantiateSingletons
                        public void preInstantiateSingletons() throws BeansException {
                        if (this.logger.isInfoEnabled()) {
                        this.logger.info("Pre-instantiating singletons in " + this);
                        }
                        synchronized (this.beanDefinitionMap) {
                        for (String beanName : this.beanDefinitionNames) {
                        RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
                        if (!bd.isAbstract() && bd.isSingleton()
                        && !bd.isLazyInit()) {
                        if (isFactoryBean(beanName)) {
                        final FactoryBean factory =
                        (FactoryBean) getBean(FACTORY_BEAN_PREFIX+ beanName);
                        boolean isEagerInit;
                        if (System.getSecurityManager() != null
                        && factory instanceof SmartFactoryBean) {
                        isEagerInit = AccessController.doPrivileged(
                        new PrivilegedAction<Boolean>() {
                        public Boolean run() {
                        return ((SmartFactoryBean) factory).isEagerInit();
                        }
                        }, getAccessControlContext());
                        }
                        else {
                        isEagerInit = factory instanceof SmartFactoryBean
                        && ((SmartFactoryBean) factory).isEagerInit();
                        }
                        if (isEagerInit) {
                        getBean(beanName);
                        }
                        }
                        else {
                        getBean(beanName);
                        }
                        }
                        }
                        }
                        }
                        

杩?#38322;?#37713;?#37916;?#27996;?#28051;涓?#38344;炲父閲嶈?#20346;殑 Bean 鈥?#37413;?FactoryBean锛屽彲?#20114;璇?Spring 涓澶?#37719;婄殑鎵?#28766;曠殑鍔?#38003;?#38318;?#28051;?#26473;?#28051;?Bean 鏈夊叧锛?#26473;欐槸涓?#37911;规畩?#27537; Bean 浠栨槸涓?#23480;?#37720;?Bean锛屽彲?#20114;浜?#37922;?Bean ?#27537; Bean锛?#26473;?#38322;岀殑浜?#37922;?Bean ?#27128;鎸?Bean ?#27537;瀹炰緥锛屽鏋?#28051;涓被缁?#37813;?FactoryBean 鐢?#37812;峰彲?#20114;?#22172;宸?#28729;氫箟浜?#37922;?#28729;炰緥瀵硅薄?#27537;鏂规硶鍙?#29781;?#28729;?#37916;?#28000;栫殑 getObject 鏂规硶銆傜劧鑰?#37734;?Spring 鍐?#38318;?#26473;?#28051;?Bean ?#27537;瀹炰緥瀵硅薄?#27128; FactoryBean锛?#38315;氳繃?#30367;鐢?#26473;?#28051;?#28725;硅薄?#27537; getObject 鏂规硶灏?#38003;?#38014;峰彇鐢埛?#22172;瀹氫箟浜?#37922;熺殑瀵硅薄锛?#28000;?#38000;?#28051;? Spring ?#24385;渚?#27996;?#23536;堝?#30028;殑鎵?#28766;?#37804;?#37510;係pring 鑾峰彇 FactoryBean 鏈韩?#27537;瀵硅薄?#27128;鍦墠闈?#37716;?#28051;?& 鏉?#28729;屾垚?#27537;銆?/p>

濡?#28003;?#37714;涘缓 Bean ?#27537;瀹炰緥瀵硅薄?#20114;鍙婂浣?#37835;勫缓 Bean 瀹炰緥瀵硅薄涔?#38338;寸殑鍏?#38001;?#37711;?#32495;?#23534;?Spring 涓殑涓涓?#37837;?#36423;?#37711;?#38335;?#38171;?#28051;?#38344;槸杩?#28051;?#26473;囩?#23340;殑娴?#32459;嬪浘銆?/p>
鍥?13.Bean 瀹炰緥鍒涘缓娴?#32459;嬪浘
鍥?13.Bean 瀹炰緥鍒涘缓娴?#32459;嬪浘

锛?#37836;?#37930;?鍥?13 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

濡?#37835;滄槸鏅?#38315;氱殑 Bean 灏辩?#23384;帴鍒涘缓浠栫殑瀹炰緥锛屾槸閫氳繃?#30367;鐢?getBean 鏂规硶銆?#28051;?#38344;槸鍒涘缓 Bean 瀹炰緥?#27537;鏃跺簭鍥?#38171;?/p>
鍥?14.Bean 瀹炰緥鍒涘缓鏃跺簭鍥?/font>
鍥?14.Bean 瀹炰緥鍒涘缓鏃跺簭鍥? src=

锛?#37836;?#37930;?鍥?14 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

杩?#37832;?#28051;涓?#38344;炲父閲嶈?#20346;殑閮垎灏辨槸寤?#32468;?Bean 瀵硅薄瀹炰緥涔?#38338;寸殑鍏?#32495;?#38171;?#26473;欎?#29112;槸 Spring 妗?#37835;剁殑鏍?#36423;冪珵浜夊姏锛?#28003;曟椂銆?#28641;?#28003;曞缓绔嬩粬浠?#28052;?#38338;寸殑鍏?#32495;?#29831;?#37930;?#28051;?#38344;殑鏃跺簭鍥?#38171;?/p>
鍥?15.Bean 瀵硅薄鍏?#32495;诲缓绔?/font>
鍥?15.Bean 瀵硅薄鍏?#32495;诲缓绔? src=

锛?#37836;?#37930;?鍥?15 ?#27537;娓呮?#25198;増鏈?/font>銆?#38171;?/p>

Ioc 瀹瑰櫒?#27537;鎵?#28766;曠偣

鐜?#37734;?#26473;?#37832;?#28051;涓棶棰?#28751;辨槸濡?#28003;?#29825;?#26473;?#27996;?Bean 瀵硅薄鏈?#28051;瀹氱殑鎵?#28766;?#37804;?#38171;?#28751;辨槸?#24434;?#20114;鍔犲叆鐢埛?#27537;涓浜涙搷浣?#37510;?#38317;?#28052;?#37832;夊摢浜涙墿灞曠偣鍛?#38171;?Spring 鍙堟槸濡?#28003;曡皟鐢埌杩?#27996;涙墿灞曠偣?#27537;锛?/p>

瀵?Spring ?#27537; Ioc 瀹瑰櫒鏉?#29831;?#38171;?#28051;?#29781;?#37832;?#26473;欎箞鍑?#28051;?#37510;侭eanFactoryPostProcessor锛? BeanPostProcessor銆?#28000;?#28000;垎鍒槸鍦?#37835;勫缓 BeanFactory 鍜屾?#21227;缓 Bean 瀵硅薄?#26882;?#30367;鐢?#37510;?#26473;?#37832;?#28751;辨槸 InitializingBean ?#25328; DisposableBean 浠?#28000;垎鍒槸鍦?Bean 瀹炰緥鍒涘?#21700;拰閿姣佹椂琚皟鐢?#37510;?#37922;?#37812;峰彲?#20114;瀹?#37916;?#26473;?#27996;涙帴鍙?#28051;?#28729;氫?#22796;殑鏂规硶锛孲pring 灏变細鍦?#38315;傚綋?#27537;鏃跺欒皟鐢?#28000;?#28000;?#37510;?#26473;?#37832;?#28051;涓槸 FactoryBean 浠栨槸涓?#37911;规畩?#27537; Bean锛?#26473;?#28051;?Bean ?#24434;?#20114;琚?#37922;埛鏇?#28598;氱殑鎺?#37714;?#37510;?/p>

杩?#27996;涙墿灞曠偣閫氬父涔熸槸鎴?#28000;?#28003;?#37922;?Spring 鏉?#28729;屾垚鎴?#28000;?#37911;?#28729;氫?#35826;?#27537;鍦?#37826;?#38171;屽浣?#32494;?#38315;?Spring 灏辩?#23337;綘鏈夋病鏈夋?#23678;彙濂?Spring 鏈夊摢浜涙墿灞曠偣锛?#39582;?#28051;?#28641;?#28003;?#28003;?#37922;?#28000;?#28000;?#38171;?#29781;?#37933;?#38316;撳浣?#28003;?#37922;?#28000;?#28000;?#28751;卞繀椤?#27996;?#29785;?#28000;?#28000;?#37712;?#37734;殑鏈?#37918;?#37510;傚彲?#20114;鐢?#28051;?#38344;?#28051;涓?#23011;斿鏉?#29785;?#38322;?#37510;?/p>

鎴?#28000;?#37814;?Ioc 瀹瑰櫒姣?#28003;?#28051;涓?#32480;卞瓙锛?#26473;?#28051;?#32480;卞瓙閲?#37832;夎骞?#28051;?#37918;冪殑妯?#28699;?#38171;屽彲?#20114;鐢?#26473;?#27996;涙瀛?#37833;?#38315;?#23536;?#28598;?#32457;?#28051;?#37722;岀殑鐞?#38171;?#26473;?#37832;?#28051;涓?#38315;?#26473;?#27996;?#37918;冩?#27537;鏈哄櫒锛?#26473;?#28051;?#37832;哄櫒?#24434;?#20114;浜?#37922;?#37918;冩銆?#38317;?#28052;?#28000;?#28000;殑瀵?#25652;?#37711;? 绯?#28751;辨槸 BeanFactory 灏辨槸閭?#28051;?#38315;?#37918;冩?#27537;鏈哄櫒锛岀?#20905;灏辨槸 Bean锛?#38000;岀?#20905;閫?#37713;?#37833;殑鐞?#28751;辨槸 Bean ?#27537;瀹炰緥銆?#38317;墠闈?#37813;璇寸殑鍑?#28051;?#37813;?#28766;曠偣鍙?#37734;?#28000;涔?#37734;?#37826;瑰憿锛?BeanFactoryPostProcessor 瀵?#25652;斿埌?#32139;閫?#37918;冩琚?#38315;?#37713;?#37833;椂锛?#28003;?#28751;?#37832;?#37832;轰細?#24434;?#20114;瀵?#37711;跺仛鍑?#29825;惧綋?#27537;淇?#23005;?#38171;?#28052;?#28751;辨槸浠栧彲?#20114;甯?#28003;犱慨?#25980;鐞冩銆?#38000;?InitializingBean ?#25328; DisposableBean ?#27128;鍦?#37918;冩閫?#37918;冪殑寮濮嬪拰缁撴潫闃舵锛?#28003;犲彲?#20114;瀹屾垚涓浜涢?#21227;?#22247;?#23678;灏?#23480;?#28003;?#37510;侭eanPostProcessor 灏卞彲?#20114;璁?#28003;犲鐞冩閫?#37713;?#37833;殑鐞?#37707;?#37713;?#38315;傚綋?#27537;淇?#23005;?#37510;?#37832;鍚?#26473;?#37832;?#28051;涓? FactoryBean锛?#28729;冨彲?#27128;涓涓?#32449;?#28610;囩殑鐞冩銆?#26473;?#28051;?#37918;冩涓嶆槸棰勫厛灏?#28729;氬瀷浜?#38171;?#38000;屾槸鐢?#28003;犳潵缁?#28000;?#32429;?#28729;?#28729;冪殑褰姸锛屾?#21159;浣犲彲?#20114;纭?#28729;氳繖涓?#37918;冩鍨嬬殑褰姸锛屽綋?#21159;浠?#38315;?#37713;?#37833;? ?#27537;鐞冭瀹?#28751;辨槸浣犳兂瑕佺殑鐞?#27996;?#38171;?#26473;?#37837;?#37734;?#26473;?#28051;?#32480;卞瓙閲?#28751;煎彲?#20114;鍙?#37916;?#37813;鏈?#28003;犳兂瑕佺殑鐞?/p>

Ioc 瀹瑰櫒濡?#28003;?#28051;?#37812;?#37813;鐢?/strong>

?#22688;闈殑浠?#32513;?#27996;?Spring 瀹瑰櫒?#27537;鏋勫缓杩囩锛?#38317;?Spring 鑳?#28051;?#37812;?#28000;?#37707;氫粈涔?#38171;孲pring ?#27537; Ioc 瀹瑰櫒鍙?#38003;?#37707;氫粈涔堝憿锛熸垜浠?#28003;?#37922;? Spring 蹇?#26916;?#29781;侀鍏?#37835;勫缓 Ioc 瀹瑰櫒锛屾病鏈?#28729;?Spring 鏃犳硶宸?#28003;?#38171;孉pplicatonContext.xml 灏辨槸 Ioc 瀹瑰櫒?#27537;榛?#29825;?#38320;嶇疆鏂囦欢锛孲pring ?#27537;鎵鏈?#37911;?#37804;?#37716;?#38003;?#38318;芥槸?#29056;浜?#26473;?#28051;?Ioc 瀹瑰櫒宸?#28003;滅殑锛?#23011;?#28641;?#37722;?#38344;?#29781;?#28000;?#32513;嶇殑 AOP銆?/p>

Ioc 瀹?#28729;?#38340;?#28051;?#28751;辨槸涓?#28003;?#37835;勫缓浜?#28051;涓瓟鏂?#38171;孲pring 涓?#28003;犳濂?#27996;?#26976;?#26976;?#37835;?#37835;?#38171;?#26473;?#28051;瓟鏂瑰埌搴?#38003;?#37721;?#37713;?#28000;涔堝?#30028;殑涓滆鍑?#37833;?#38171;?#26473;欏繀椤?#29781;?#37832;?#28003;犵殑鍙?#28051;?#37510;?#38317;?#37812;?#28000;?#37804;?#28052;?#37721;?#28051;?#38171;?#26473;?#28751;辨槸?#22688;闈?#29831;寸殑瑕?#27996;?#29785;?Spring 涓?#38317;?#37832;?#27996;涙墿灞曠偣锛屾垜浠?#38315;氳繃瀹?#37916;?#38317;?#27996;涙墿灞曠偣鏉敼鍙?Spring ?#27537;閫?#37922;?#29723;?#28051;?#37510;?#38007;?#27996;庡浣?#28729;?#37916;?#37813;?#28766;曠偣鏉?#23536;楀埌鎴?#28000;?#37807;?#29781;佺殑涓?#37804;?#32513;?#37835;?#38171;孲pring 涓?#37832;夊緢澶氫緥瀛?#38171;屽叾涓?AOP ?#27537;瀹?#37916;?#28751;辨槸 Spring 鏈韩瀹?#37916;?#27996;嗗叾鎵?#28766;曠偣鏉?#26440;惧埌浜?#28729;?#37807;?#29781;佺殑鐗?#37804;?#37716;?#38003;?#38171;屽彲?#20114;鎷?#37833;?#37721;?#38000;?#37510;?/p>


Spring 涓?AOP 鐗?#37804;?#29831;?#29785;?/strong>

鍔?#37804;?#28000;?#37918;嗙殑瀹?#37916;板師鐞?/strong>

瑕?#27996;?#29785;?Spring ?#27537; AOP 灏卞繀椤诲厛浜?#29785;殑鍔?#37804;?#28000;?#37918;嗙殑?#24107;鐞?#38171;屽洜涓?AOP 灏辨槸?#29056;浜庡姩鎬?#28000;?#37918;?#28729;?#37916;扮殑銆?#37716;?#37804;?#28000;?#37918;?#26473;?#29781;?#28000;?JDK 鏈韩璇?#29863;?#37510;?/p>

鍦?Jdk ?#27537; java.lang.reflect 鍖?#28051;?#37832;?#28051;?Proxy ?#34987;锛?#28729;?#23005;槸鏋?#38315;?#28000;?#37918;嗙被?#27537;鍏?#37721;?#37510;?#26473;?#28051;被?#27537;缁?#37835;勫叆涓?#38171;?/p>
鍥?16. Proxy ?#34987;缁?#37835;?/font>
鍥?16. Proxy ?#34987;缁?#37835;? src=

浠?#28051;婂浘鍙?#37916;?#37832;鍚?#38344;?#37733;?#28051;槸鍏?#37832;?#37826;规硶銆?#38000;?#37832;鍚?#28051;涓?#37826;规硶 newProxyInstance 灏辨槸鍒涘缓浠?#37918;嗗?#30789;薄?#27537;鏂规硶銆?#26473;?#28051;?#37826;规硶?#27537;?#31790;?#29212;濡?#28051;?#38171;?/p>
娓呭崟 6. Proxy. newProxyInstance
                        public static Object newProxyInstance(ClassLoader loader,
                        Class<?>[] interfaces,
                        InvocationHandler h)
                        throws IllegalArgumentException {
                        if (h == null) {
                        throw new NullPointerException();
                        }
                        Class cl = getProxyClass(loader, interfaces);
                        try {
                        Constructor cons = cl.getConstructor(constructorParams);
                        return (Object) cons.newInstance(new Object[] { h });
                        } catch (NoSuchMethodException e) {
                        throw new InternalError(e.toString());
                        } catch (IllegalAccessException e) {
                        throw new InternalError(e.toString());
                        } catch (InstantiationException e) {
                        throw new InternalError(e.toString());
                        } catch (InvocationTargetException e) {
                        throw new InternalError(e.toString());
                        }
                        }
                        

杩?#28051;?#37826;规硶?#28214;瑕?#28051;?#28051;?#37721;傛暟锛欳lassLoader锛?#37922;?#27996;庡姞杞?#28000;?#37918;嗙被?#27537; Loader ?#34987;锛?#38315;氬父杩?#28051;?Loader ?#25328;琚?#28000;?#37918;嗙殑?#34987;?#27128;鍚?#28051;涓? Loader ?#34987;銆侷nterfaces锛屾槸瑕?#29722;?#28000;?#37918;嗙殑閭?#27996;?#38317;?#27996;涙帴鍙?#37510;侷nvocationHandler锛?#28751;辨槸鐢?#27996;?#37813;?#29723;岄櫎浜?#29722;?#28000;?#37918;嗘帴鍙?#28051;?#37826;规硶涔嬪?#26667;殑鐢埛?#22172;瀹氫?#22796;殑鎿?#28003;?#38171;? 浠?#28052;熸槸鐢埛?#28214;瑕?#28000;?#37918;嗙殑鏈缁堢洰?#27537;銆?#37922;埛?#30367;鐢洰鏍?#37826;规硶閮?#29722;?#28000;?#37918;嗗埌 InvocationHandler ?#34987;涓?#28729;氫?#22796;殑?#25966;涓鏂规硶 invoke 涓?#37510;?#26473;?#37734;?#37722;?#38344;?#37712;?#29831;?#29785;?#37510;?/p>

涓?#38344;?#26473;樻槸鐪?#37930;?Proxy 濡?#28003;?#27996;?#37922;?#28000;?#37918;嗙被?#27537;杩囩锛?#28000;?#37835;?#38315;?#37713;?#37833;殑浠?#37918;?#32491;诲埌搴曟槸浠涔?#37837;峰瓙锛?#28051;?#38344;?#37819;?#37829;撳暒銆?/p>
鍥?17. 鍒涘缓浠?#37918;嗗?#30789;薄鏃跺簭鍥?/font>
鍥?17. 鍒涘缓浠?#37918;嗗?#30789;薄鏃跺簭鍥? src=

鍏?#28729;炰粠涓婂浘涓彲?#20114;鍙?#37916;?#23005;?#37734;?#37835;?#38315;?#28000;?#37918;嗙被?#27537;?#27128;鍦?ProxyGenerator ?#27537; generateProxyClass ?#27537;鏂规硶涓?#37510;侾roxyGenerator ?#34987;鍦?sun.misc 鍖?#28051;?#38171;屾劅鍏磋叮?#27537;璇濆彲?#20114;鐪?#37930;嬩粬?#27537;?#31790;?#29212;銆?/p>

?#20131;濡?#37832;?#26473;?#37837;?#28051;涓?#37818;?#37721;?#38171;屽涓?#38171;?/p>
娓呭崟 7. SimpleProxy ?#34987;
                        public interface SimpleProxy {
                        public void simpleMethod1();
                        public void simpleMethod2();
                        }
                        

浠?#37918;嗘潵鐢熸垚?#27537;?#34987;缁?#37835;勫涓?#38171;?/p>
娓呭崟 8. $Proxy2 ?#34987;
                        public class $Proxy2 extends java.lang.reflect.Proxy implements SimpleProxy{
                        java.lang.reflect.Method m0;
                        java.lang.reflect.Method m1;
                        java.lang.reflect.Method m2;
                        java.lang.reflect.Method m3;
                        java.lang.reflect.Method m4;
                        int hashCode();
                        boolean equals(java.lang.Object);
                        java.lang.String toString();
                        void simpleMethod1();
                        void simpleMethod2();
                        }
                        

杩?#28051;被涓殑鏂规硶閲?#38344;?#28751;嗕細?#27128;?#30367;鐢?InvocationHandler ?#27537; invoke 鏂规硶锛?#38000;?#23011;?#28051;?#37826;规硶涔?#28751;嗗搴?#28051;涓睘鎬?#37721;?#38322;?#38171;?#26473;?#28051;睘鎬?#37721;?#38322;?m 涔?#28751;?#28028;?#32513;?invoke 鏂规硶涓殑 Method 鍙傛暟銆傛暣涓?#28000;?#37918;?#28751;辨槸杩?#37837;?#28729;?#37916;扮殑銆?/p>

Spring AOP 濡?#28003;?#28729;?#37916;?/strong>

浠庡墠闈?#28000;?#37918;嗙殑?#24107;鐞嗘垜浠?#37933;亾锛?#28000;?#37918;嗙殑?#27952;?#27537;?#27128;?#30367;鐢洰鏍?#37826;规硶?#26882;鎴?#28000;彲?#20114;?#27974;鑰屾墽琛?InvocationHandler ?#34987;?#27537; invoke 鏂规硶锛屾墍?#20114;濡?#28003;?#37734;?InvocationHandler 涓婂仛鏂囩珷灏辨槸 Spring 瀹?#37916;?Aop ?#27537;鍏?#38335;?#37813;鍦?#37510;?/p>

Spring ?#27537; Aop 瀹?#37916;版槸閬?#28729;?Aop 鑱?#37929;熺殑绾?#28729;?#37510;?#37722;屾椂 Spring 鍙?#37813;?#28766;?#27996;?#28729;?#38171;屽鍔?#27996;嗗 Pointcut銆丄dvisor 绛?#28051;浜涙帴鍙?#28003;?#23536;楁洿鍔?#37903;垫椿銆?/p>

涓?#38344;槸 Jdk 鍔?#37804;?#28000;?#37918;嗙殑绫诲浘锛?/p>
鍥?18. Jdk 鍔?#37804;?#28000;?#37918;嗙殑绫诲浘
鍥?18. Jdk 鍔?#37804;?#28000;?#37918;嗙殑绫诲浘

涓婂?#28844;?#21614;?#27697;殑鏄剧浜?Spring 寮?#37922;?#27996;?Aop Alliance 瀹氫?#22796;殑鎺?#37721;?#37510;?#28654;?#28051;?#28051;嶈璁?Spring 濡?#28003;?#37813;?#28766;?Aop Alliance锛屽厛鐪?#37930;?Spring 濡?#28003;?#28729;?#37916;?#28000;?#37918;嗙被?#27537;锛?#29781;?#28729;?#37916;?#28000;?#37918;嗙被鍦?Spring ?#27537;閰嶇疆鏂囦欢涓?#38315;氬父?#27128;杩?#37837;?#28729;?#28051;涓?Bean ?#27537;锛屽涓?#38171;?/p>
娓呭崟 9. 閰嶇疆浠?#37918;嗙被 Bean
                        <bean id="testBeanSingleton"
                        class="org.springframework.aop.framework.ProxyFactoryBean">
                        <property name="proxyInterfaces">
                        <value>
                        org.springframework.aop.framework.PrototypeTargetTests$TestBean
                        </value>
                        </property>
                        <property name="target"><ref local="testBeanTarget"></ref> </property>
                        <property name="singleton"><value>true</value></property>
                        <property name="interceptorNames">
                        <list>
                        <value>testInterceptor</value>
                        <value>testInterceptor2</value>
                        </list>
                        </property>
                        </bean>
                        

閰嶇疆涓?#37930;嬪埌瑕?#29825;剧疆琚?#28000;?#37918;嗙殑鎺?#37721;?#38171;屽?#23678;帴鍙殑瀹?#37916;扮被涔?#28751;辨槸?#27952;鏍囩被锛屼互鍙?#37815;?#37812;櫒涔?#28751;?#37734;?#37813;?#29723;岀洰鏍?#37826;规硶涔嬪墠琚皟鐢?#38171;?#26473;?#38322;?Spring 涓?#28729;氫?#22796;殑鍚?#32457;?#37722;?#37837;风殑鎷?#37812;櫒锛屽彲?#20114;閫夋嫨浣?#37922;?#37510;?/p>

涓?#38344;?#37930;?#37930;?Spring 濡?#28003;?#28729;屾垚浜?#28000;?#37918;嗕互鍙婃槸濡?#28003;曡皟鐢?#37815;?#37812;櫒?#27537;銆?/p>

?#22688;闈?#37819;愬埌 Spring Aop 涔熸槸瀹?#37916;?#37711;惰嚜?#38889;?#27537;鎵?#28766;曠偣鏉?#28729;屾垚杩?#28051;?#37911;?#37804;殑锛?#28000;?#26473;?#28051;?#28000;?#37918;?#32491;诲彲?#20114;鐪?#37713;?#28729;?#23005;槸缁?#37813;?#27996;?FactoryBean ?#27537; ProxyFactoryBean锛孎actoryBean 涔?#37813;?#20114;鐗?#37714;?#28751;?#37734;?#28729;冨彲?#20114;璁?#28003;犺嚜瀹氫?#22794;?#30789;薄?#27537;鍒涘缓鏂规硶銆傚綋?#21159;浠?#37918;嗗?#30789;薄瑕?#38315;氳繃 Proxy ?#34987;鏉?#37716;?#37804;?#37922;熸垚銆?/p>

涓?#38344;槸 Spring 鍒涘缓?#27537;浠?#37918;嗗?#30789;薄?#27537;鏃跺簭鍥?#38171;?/p>
鍥?19.Spring 浠?#37918;嗗?#30789;薄?#27537;浜?#37922;?/font>
鍥?19.Spring 浠?#37918;嗗?#30789;薄?#27537;浜?#37922;? src=

Spring 鍒涘缓浜?#28000;?#37918;嗗?#30789;薄鍚?#38171;屽綋浣犺皟鐢洰鏍?#28725;硅薄涓婄殑鏂规硶?#26882;锛?#28751;?#38318;戒細琚?#28000;?#37918;嗗埌 InvocationHandler ?#34987;?#27537; invoke 鏂规硶涓?#37813;?#29723;?#38171;?#26473;?#37734;墠闈?#23480;?#32513;忚閲?#37510;?#37734;?#26473;?#38322;?JdkDynamicAopProxy ?#34987;瀹?#37916;?#27996;?InvocationHandler 鎺?#37721;?#37510;?/p>

涓?#38344;?#37712;嶇湅鐪?Spring ?#27128;濡?#28003;曡皟鐢?#37815;?#37812;櫒?#27537;锛?#28051;?#38344;槸杩?#28051;?#26473;囩?#23340;殑鏃跺簭鍥?#38171;?/p>
鍥?20.Spring ?#30367;鐢?#37815;?#37812;櫒
鍥?20.Spring ?#30367;鐢?#37815;?#37812;櫒

?#20114;涓?#37813;璇寸殑閮芥槸 Jdk 鍔?#37804;?#28000;?#37918;?#38171;孲pring 杩樻敮鎸?#28051;绉?CGLIB ?#34987;浠?#37918;?#38171;屾劅鍏磋叮?#22172;宸辩湅鍚?#37510;?/p>


Spring 涓?#29825;?#29825;?#22959;?#23534;忓垎?#28733;

Spring 涓?#28003;?#37922;殑璁?#29825;?#22959;?#23534;?#28052;?#23536;?#28598;?#38171;?#23011;?#28641;?#23480;?#37720;傛寮?#37510;?#37719;曚緥妯?#23534;?#37510;?#22959;?#37911;?#22959;?#23534;?#32475;?#38171;?#37734;?#37510;?Webx 妗?#37835;剁殑绯?#32513;?#37835;?#37835;?#28051;?#29825;?#29825;?#22959;?#23534;?#37510;?#37510;?#37510;?Tomcat ?#27537;绯?#32513;?#37835;?#37835;?#28051;?#22959;?#23534;忚璁垎?#28733;銆嬪凡缁?#37832;?#28000;?#32513;?#38171;?#26473;?#38322;?#28751;?#28051;嶈禈杩?#27996;?#37510;?#26473;?#38322;?#28051;?#29781;?#28000;?#32513;?#28000;?#37918;嗘寮忓拰绛?#37923;?#22959;?#23534;?#37510;?/p>

浠?#37918;嗘寮?/strong>

浠?#37918;嗘寮忓師鐞?/strong>

浠?#37918;嗘寮?#28751;辨槸缁欐煇涓涓?#28725;硅薄鍒涘缓涓涓?#28000;?#37918;嗗?#30789;薄锛?#38000;?#37922;?#26473;?#28051;?#28000;?#37918;嗗?#30789;薄鎺?#37714;跺?#29808;師瀵硅薄?#27537;寮?#37922;?#38171;?#38000;?#37714;涘缓杩?#28051;?#28000;?#37918;嗗?#30789;薄灏辨槸?#24434;?#20114;鍦皟鐢師瀵硅薄?#27128;?#24434;?#20114;澧?#37716;?#28051;浜涢?#28614;?#26667;殑鎿?#28003;?#37510;?#28051;?#38344;槸浠?#37918;嗘寮忕殑缁?#37835;?#38171;?/p>
鍥?21. 浠?#37918;嗘寮忕殑缁?#37835;?/font>
鍥?21. 浠?#37918;嗘寮忕殑缁?#37835;? src=

  • Subject锛?#37814;借薄涓?#26864;?#38171;?#28729;冩槸浠?#37918;嗗?#30789;薄?#27537;鐪?#28729;?#28725;硅薄瑕?#28729;?#37916;扮殑鎺?#37721;?#38171;屽綋?#21159;杩欏彲?#20114;?#27128;澶?#28051;?#37818;?#37721;?#32513;勬垚銆?
  • ProxySubject锛氫唬鐞嗙被闄?#27996;?#28729;?#37916;?#37814;借薄涓?#26864;?#28729;氫?#22796;殑鎺?#37721;?#28598;?#38171;?#26473;?#36423;?#26916;?#37816;?#37832;?#37813;浠?#37918;嗗?#30789;薄?#27537;寮?#37922;?
  • RealSubject锛氳浠?#37918;嗙殑?#34987;锛屾槸?#27952;鏍?#28725;硅薄銆?

Spring 涓?#28641;?#28003;?#28729;?#37916;?#28000;?#37918;嗘寮?/strong>

Spring Aop 涓?Jdk 鍔?#37804;?#28000;?#37918;?#28751;辨槸鍒?#37922;?#28000;?#37918;嗘寮?#37814;鏈?#28729;?#37916;扮殑銆?#37734;?Spring 涓?#38340;?#27996;?#28729;?#37916;拌浠?#37918;嗗?#30789;薄?#27537;鎺?#37721;?#28598;?#38171;?#26473;樹細鏈? org.springframework.aop.SpringProxy ?#25328; org.springframework.aop.framework.Advised 涓?#28051;?#37818;?#37721;?#37510;係pring 涓?#28003;?#37922;?#28000;?#37918;嗘寮忕殑缁?#37835;勫?#24807;涓?#38171;?/p>
鍥?22. Spring 涓?#28003;?#37922;?#28000;?#37918;嗘寮忕殑缁?#37835;勫浘
鍥?22. Spring 涓?#28003;?#37922;?#28000;?#37918;嗘寮忕殑缁?#37835;勫浘

$Proxy 灏辨槸鍒涘缓?#27537;浠?#37918;嗗?#30789;薄锛?#38000;?Subject ?#27128;鎶借薄涓?#26864;?#38171;?#28000;?#37918;嗗?#30789;薄?#27128;閫氳繃 InvocationHandler 鏉?#37816;?#37832;夊?#22317;洰鏍?#28725;硅薄?#27537;寮?#37922;殑銆?/p>

Spring 涓?#28051;涓?#37930;?#28729;炵殑浠?#37918;嗗?#30789;薄缁?#37835;勫涓?#38171;?/p>
娓呭崟 10 浠?#37918;嗗?#30789;薄 $Proxy4
                        public class $Proxy4 extends java.lang.reflect.Proxy implements
                        org.springframework.aop.framework.PrototypeTargetTests$TestBean
                        org.springframework.aop.SpringProxy
                        org.springframework.aop.framework.Advised
                        {
                        java.lang.reflect.Method m16;
                        java.lang.reflect.Method m9;
                        java.lang.reflect.Method m25;
                        java.lang.reflect.Method m5;
                        java.lang.reflect.Method m2;
                        java.lang.reflect.Method m23;
                        java.lang.reflect.Method m18;
                        java.lang.reflect.Method m26;
                        java.lang.reflect.Method m6;
                        java.lang.reflect.Method m28;
                        java.lang.reflect.Method m14;
                        java.lang.reflect.Method m12;
                        java.lang.reflect.Method m27;
                        java.lang.reflect.Method m11;
                        java.lang.reflect.Method m22;
                        java.lang.reflect.Method m3;
                        java.lang.reflect.Method m8;
                        java.lang.reflect.Method m4;
                        java.lang.reflect.Method m19;
                        java.lang.reflect.Method m7;
                        java.lang.reflect.Method m15;
                        java.lang.reflect.Method m20;
                        java.lang.reflect.Method m10;
                        java.lang.reflect.Method m1;
                        java.lang.reflect.Method m17;
                        java.lang.reflect.Method m21;
                        java.lang.reflect.Method m0;
                        java.lang.reflect.Method m13;
                        java.lang.reflect.Method m24;
                        int hashCode();
                        int indexOf(org.springframework.aop.Advisor);
                        int indexOf(org.aopalliance.aop.Advice);
                        boolean equals(java.lang.Object);
                        java.lang.String toString();
                        void sayhello();
                        void doSomething();
                        void doSomething2();
                        java.lang.Class getProxiedInterfaces();
                        java.lang.Class getTargetClass();
                        boolean isProxyTargetClass();
                        org.springframework.aop.Advisor; getAdvisors();
                        void addAdvisor(int, org.springframework.aop.Advisor)
                        throws org.springframework.aop.framework.AopConfigException;
                        void addAdvisor(org.springframework.aop.Advisor)
                        throws org.springframework.aop.framework.AopConfigException;
                        void setTargetSource(org.springframework.aop.TargetSource);
                        org.springframework.aop.TargetSource getTargetSource();
                        void setPreFiltered(boolean);
                        boolean isPreFiltered();
                        boolean isInterfaceProxied(java.lang.Class);
                        boolean removeAdvisor(org.springframework.aop.Advisor);
                        void removeAdvisor(int)throws org.springframework.aop.framework.AopConfigException;
                        boolean replaceAdvisor(org.springframework.aop.Advisor,
                        org.springframework.aop.Advisor)
                        throws org.springframework.aop.framework.AopConfigException;
                        void addAdvice(org.aopalliance.aop.Advice)
                        throws org.springframework.aop.framework.AopConfigException;
                        void addAdvice(int, org.aopalliance.aop.Advice)
                        throws org.springframework.aop.framework.AopConfigException;
                        boolean removeAdvice(org.aopalliance.aop.Advice);
                        java.lang.String toProxyConfigString();
                        boolean isFrozen();
                        void setExposeProxy(boolean);
                        boolean isExposeProxy();
                        }
                        

绛?#37923;?#22959;?#23534;?/strong>

绛?#37923;?#22959;?#23534;忓師鐞?/strong>

绛?#37923;?#22959;?#23534;忛鍚?#37804;?#28052;?#28751;辨槸鍋氭煇浜嬬殑绛?#37923;?#38171;?#26473;?#37734;紪绋?#28051;?#38315;氬父?#27128;鎸?#28729;屾垚鏌?#28051;?#37823;?#28003;滃彲鑳?#37832;夊绉?#37826;规硶锛?#26473;?#27996;涙?#35268;硶鍚?#37832;夊绉?#38171;屽彲鑳?#37832;?#28051;?#37722;岀殑閫?#25652;旂殑鍦?#37722;?#38171;岀劧鑰?#26473;?#27996;涙搷浣?#37826;规硶閮?#37832;夊彲鑳?#37922;埌銆?#37722;?#28051;涓?#37823;?#28003;?#37826;规硶閮藉綋浣?#28051;涓?#28729;?#37916;?#32475;?#37923;?#38171;?#28003;?#37922;?#38000;呭彲鑳?#37837;规嵁?#28214;瑕?#38315;夋嫨鍚?#38315;傜殑绛?#37923;?#37510;?/p>

涓?#38344;槸绛?#37923;?#22959;?#23534;忕殑缁?#37835;?#38171;?/p>
鍥?23. 绛?#37923;?#22959;?#23534;忕殑缁?#37835;?/font>
鍥?23. 绛?#37923;?#22959;?#23534;忕殑缁?#37835;? src=

  • Context锛氫娇鐢?#28051;?#37722;?#32475;?#37923;殑?#24134;澧?#38171;?#28729;冨彲?#20114;鏍规嵁?#22172;?#38889;?#27537;鏉欢閫夋嫨涓?#37722;岀殑绛?#37923;?#28729;?#37916;扮被鏉?#28729;屾垚鎵瑕佺殑鎿?#28003;?#37510;?#28729;冩寔鏈?#28051;涓?#32475;?#37923;?#28729;炰緥?#27537;寮?#37922;?#37510;?#37714;涘缓鍏蜂綋绛?#37923;?#28725;硅薄?#27537;鏂规硶涔熷彲?#20114;鐢?#28000;?#28729;屾垚銆?
  • Strategy锛?#37814;借薄绛?#37923;?#38171;?#28729;氫箟姣?#28051;?#32475;?#37923;?#38318;?#29781;?#28729;?#37916;扮殑绛?#37923;?#37826;规硶
  • ConcreteStrategy锛氬?#34562;綋绛?#37923;?#28729;?#37916;扮被锛?#28729;?#37916;?#37814;借薄绛?#37923;?#28051;?#28729;氫?#22796;殑绛?#37923;?#37826;规硶

Spring 涓?#32475;?#37923;?#22959;?#23534;忕殑瀹?#37916;?/strong>

Spring 涓?#32475;?#37923;?#22959;?#23534;?#28003;?#37922;?#37832;夊涓?#37734;?#37826;?#38171;屽 Bean 瀹氫?#22794;?#30789;薄?#27537;鍒涘?#36720;互鍙?#28000;?#37918;嗗?#30789;薄?#27537;鍒涘缓绛?#37510;?#26473;?#38322;?#28051;?#29781;?#37930;?#28051;涓嬩唬鐞嗗?#30789;薄鍒涘缓?#27537;绛?#37923;?#22959;?#23534;忕殑瀹?#37916;?#37510;?/p>

?#22688;闈?#23480;?#32513;?#27996;?#29785;?Spring ?#27537;浠?#37918;?#37826;?#23534;?#37832;?#28051;?#28051;?Jdk 鍔?#37804;?#28000;?#37918;嗗拰 CGLIB 浠?#37918;?#37510;?#26473;?#28051;?#28051;?#28000;?#37918;?#37826;?#23534;忕殑浣?#37922;?#23005;槸浣?#37922;?#27996;?#32475;?#37923;?#22959;?#23534;?#37510;?#28729;冪殑缁?#37835;勫?#24807;涓?#37813;绀?#38171;?/p>
鍥?24. Spring 涓?#32475;?#37923;?#22959;?#23534;?#32513;?#37835;勫浘
鍥?24. Spring 涓?#32475;?#37923;?#22959;?#23534;?#32513;?#37835;勫浘

鍦?#28051;?#38344;?#32513;?#37835;勫浘涓?#28051;?#37837;?#37713;嗙殑绛?#37923;?#22959;?#23534;?#32513;?#37835;勭?#23941;井鏈夌偣涓?#37722;?#38171;?#26473;?#38322;?#37814;借薄绛?#37923;槸 AopProxy 鎺?#37721;?#38171;孋glib2AopProxy ?#25328; JdkDynamicAopProxy ?#22414;鍒?#28000;?#29723;?#28051;?#32457;嶇瓥鐣殑瀹?#37916;?#37826;?#23534;?#38171;孭roxyFactoryBean 灏辨槸浠?#29723;?Context 瑙掕壊锛?#28729;?#37837;规嵁鏉欢閫夋嫨浣?#37922;?Jdk 浠?#37918;?#37826;?#23534;忚?#27195;槸 CGLIB 鏂?#23534;?#38171;?#38000;屽彟澶?#28051;?#28051;被涓?#29781;佹槸鏉?#29840;熻矗鍒涘缓鍏蜂綋绛?#37923;?#28725;硅薄锛孭roxyFactoryBean ?#27128;閫氳?#22246;緷璧栫殑鏂规硶鏉?#37711;?#38001;?#37711;蜂綋绛?#37923;?#28725;硅薄?#27537;锛?#28729;冩槸閫氳繃?#30367;鐢?#32475;?#37923;?#28725;硅薄?#27537; getProxy(ClassLoader classLoader) 鏂规硶鏉?#28729;屾垚鎿?#28003;?#37510;?/p>


鎬?#32513;?/strong>

鏈?#37826;?#38315;氳?#22246;粠 Spring ?#27537;鍑?#28051;?#37837;?#36423;?#32513;?#28000;跺叆鎵?#38171;?#29831;?#37733;?#37813;?#37713;?#37835;勫缓 Spring 妗?#37835;剁殑楠?#26976;?#37835;?#37835;?#38171;?#26473;?#38000;屽垎?#28733; Spring 鍦?#29825;?#29825;殑涓浜?#29825;?#29825;?#37918;嗗康锛屾槸鍚?#28000;?#28051;?#37813;?#37713;?#28051;浜涘?#30028;殑璁?#29825;?#37804;?#37807;?#38171;屽?#35268;垜浠互鍚?#32459;嬪?#24538;璁?#38003;芥彁渚?#28051;浜涙濊矾銆傛帴?#28483;鍐?#29831;?#32513;嗗垎?#28733;浜?Spring 涓槸濡?#28003;?#28729;?#37916;?#26473;?#27996;?#37918;嗗康?#27537;锛屼互鍙?#37734;?#29825;?#29825;?#22959;?#23534;?#28051;婃槸濡?#28003;?#28003;?#37922;殑銆?/p>

閫氳?#22247;垎?#28733; Spring 缁欐垜涓涓?#23536;?#28598;殑鍚?#32448;?#28751;辨槸鍏?#26473;欏璁?#29825;?#37918;嗗康鍏?#28729;?#28725;规垜浠?#37832;夊緢寮虹殑鍊熼?#23384;剰涔?#38171;?#28729;?#38315;氳繃鎶借薄澶?#37833;?#28598;氬?#27196;殑瀵硅薄锛?#26473;?#28051;姝?#37707;?#29785;勮寖锛岀?#36346;悗鏍规嵁瀹?#28729;氫?#22796;殑杩欏瑙勮寖璁?#29825;?#37713;?#28051;涓?#28729;瑰櫒锛?#28729;瑰櫒涓?#37835;勫缓瀹?#28000;殑澶?#37833;?#37711;?#32495;?#38171;屽叾瀹?#37916;?#37734;?#37832;夊緢澶氭儏鍐?#38318;藉彲?#20114;鐢?#26473;?#32457;嶇被浼肩殑澶?#37918;?#37826;规硶銆?/p>

铏界劧鎴?#23536;?#37807;?#37814;?#37812;?#28725;?Spring ?#27537;鎯虫硶瀹屽叏闃?#26473;版?#21614;锛?#28003;嗘槸鎵璋?#8220;涔?#28051;?#28751;借锛岃涓?#28751;芥剰銆?#8221;锛?#37832;?#28000;涔?#28051;嶅?#35268;垨鑰?#28051;嶆?#21614;?#27697;殑鍦?#37826;?#28598;?#28729;?#26473;樻槸鐪?#37930;嬪叾?#31790;?#29212;鍚?#37510;?/p>

 ?#24107;鏂?#37734;板潃 http://www.ibm.com/developerworks/cn/java/j-lo-spring-principle/index.html

]]>
java?#24381;灏?#29831;?#29785;?/title><link>http://www.67529968.com/caizh2009/archive/2011/01/13/342941.html</link><dc:creator>灏忚彍姣?#23011;?/dc:creator><author>灏忚彍姣?#23011;?/author><pubDate>Thu, 13 Jan 2011 09:09:00 GMT</pubDate><guid>http://www.67529968.com/caizh2009/archive/2011/01/13/342941.html</guid><wfw:comment>http://www.67529968.com/caizh2009/comments/342941.html</wfw:comment><comments>http://www.67529968.com/caizh2009/archive/2011/01/13/342941.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.67529968.com/caizh2009/comments/commentRss/342941.html</wfw:commentRss><trackback:ping>http://www.67529968.com/caizh2009/services/trackbacks/342941.html</trackback:ping><description><![CDATA[     ?#25011;瑕? Java?#27537;?#24381;灏?#37832;?#37714;舵槸Java鐗?#37804;?#28052;?#28051;锛屽弽灏?#37832;?#37714;舵槸鏋勫缓妗?#37835;?#37814;鏈殑?#29056;纭鎵鍦?#37510;傜?#22443;?#32472;?#23678;彙Java?#24381;灏?#37832;?#37714;?#38171;屽澶?#28729;朵互鍚庡涔犳鏋?#37814;鏈?#37832;夊緢澶殑甯?#37716;?#37510;?    閭?#28052;?#28000;涔堟槸Java?#27537;?#24381;灏勫憿锛?       澶?#28729;?#38318;?#37933;亾锛?#29781;?#29825;Java绋嬪?#24538;兘澶?#26473;愯锛?#38317;?#28052;?#28751;卞緱璁Java?#34987;瑕?#29722;獼ava铏氭嫙鏈?#37716;?#26462;?#37510;侸ava绫诲鏋?#28051;?#29722;獼ava铏氭嫙鏈?#37716;?#26462;?#38171;屾槸涓?..  <a href='http://www.67529968.com/caizh2009/archive/2011/01/13/342941.html'>闃?#29831;诲叏鏂?/a><img src ="http://www.67529968.com/caizh2009/aggbug/342941.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/caizh2009/" target="_blank">灏忚彍姣?#23011;?/a> 2011-01-13 17:09 <a href="http://www.67529968.com/caizh2009/archive/2011/01/13/342941.html#Feedback" target="_blank" style="text-decoration:none;">鍙?#29723;?#29831;勮</a></div>]]></description></item><item><title>Java瀵硅薄搴?#37714;?#37718;?#38171;堟暣鐞嗙瘒锛?/title><link>http://www.67529968.com/caizh2009/archive/2011/01/13/342921.html</link><dc:creator>灏忚彍姣?#23011;?/dc:creator><author>灏忚彍姣?#23011;?/author><pubDate>Thu, 13 Jan 2011 05:29:00 GMT</pubDate><guid>http://www.67529968.com/caizh2009/archive/2011/01/13/342921.html</guid><wfw:comment>http://www.67529968.com/caizh2009/comments/342921.html</wfw:comment><comments>http://www.67529968.com/caizh2009/archive/2011/01/13/342921.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.67529968.com/caizh2009/comments/commentRss/342921.html</wfw:commentRss><trackback:ping>http://www.67529968.com/caizh2009/services/trackbacks/342921.html</trackback:ping><description><![CDATA[<span id="ArticleContent1_ArticleContent1_lblContent"> <p> 鍦?#32515;?#28051;?#37930;?#27996;?#23536;?#28598;?#37832;夊叧搴?#37714;?#37718;栫殑鏂? 绔?#38171;屾?#25123;嚜宸?#28052;熷啓浜?#28051;?#32481;?#38171;岀幇鍦?#37808;?#29785;?#26473;?#27996;涙?#22249;珷閮芥病鏈夊?#22557;?#30028;殑鎶婂簭鍒?#37718;?#29831;存?#21614;(鍖呮嫭鎴戣嚜宸?#37734;?#37712;?锛屾墍?#20114;鍦?#23005;?#37812;?#28751;?#37804;?#32513;撳墠浜轰互鍙婅嚜宸辩殑缁?#26976;?#38171;?#37922;?#37831;存鏄?#37828;撴?#20636;殑璇?#29815;鏉?#37819;忚堪 璇?#37832;?#37714;?#38171;屽綋?#21159;锛?#28000;嶇?#26421;細鏈?#28051;嶅?#30028;殑鍦?#37826;?#38171;屽笇鏈?#28003;?#37930;?#37722;庡彲?#20114;鎸?#37713;?#38171;?#28003;?#28051;?#28051;鍚嶇?#23338;簭鍛?#25652;?#29831;?#37711;?#37832;?#28051;?#37826;?#37818;?#32497;殑绮剧?#28850;拰寮虹?#22562;殑姹傜煡娆?#37832;?#38171;?/p> <p>搴?#37714;?#37718;栨杩?#38171;?/p> <p>      绠鍗?#37833;?#29831;?#25652;?#37714;?#37718;?#28751;辨槸涓绉?#37922;?#37833;?#28598;?#37918;嗗?#30789;薄娴佺殑鏈?#37714;?#38171;屾墍璋撳?#30789;薄娴?#28052;?#28751;辨槸灏嗗?#30789;薄?#27537;鍐?#28729;?#26473;?#29723;屾祦鍖?#38171;屾?#20346;殑姒?#36423;?#26473;?#38322;?#28051;?#37922;?#28598;氳(灏辨槸I/O)锛屾垜浠彲?#20114;瀵规祦鍖?#37722;庣殑瀵硅薄杩?#29723;? 璇诲啓鎿?#28003;?#38171;?#28052;熷彲灏嗘祦鍖?#37722;庣殑瀵硅薄浼犺緭浜庣綉缁?#28052;?#38338;?娉?#38171;氳鎯?#28751;嗗?#30789;薄浼犺緭浜庣綉缁?#36423;?#26916;?#26473;?#29723;屾祦鍖?锛?#37734;?#28725;?#28725;硅薄娴?#26473;?#29723;?#29831;诲啓鎿?#28003;滄椂?#32048;寮?#37721;?#28051;浜涢棶棰?#38171;?#38000;屽簭鍒?#37718;?#37832;?#37714;?#23005;槸鐢?#37833;? 瑙?#37712;?#26473;?#27996;涢棶棰樼殑锛?/p> <p>?#26870;棰樼殑寮?#37713;?#38171;?/p> <p>      濡?#28051;?#37813;杩?#38171;?#29831;诲啓瀵硅薄?#32048;鏈?#28000;涔堥棶棰樺憿锛?#23011;?#28641;?#38171;氭?#25123;灏嗗?#30789;薄?#21843;鍏?#28051;涓?#32446;?#37929;?#37826;囦欢鑰?#37722;庡啀灏嗗叾璇?#37713;?#37833;細鏈?#28000;涔堥棶棰?#37722;?#38171;?#37714;?#37804;?#38171;屽叾涓?#28051;涓?#37832;澶殑?#26870;棰?#28751;辨槸瀵硅薄寮?#37922;?#38171;?#28051;?#28051;緥瀛? 鏉?#29831;?#38171;氬亣濡傛垜鏈?#28051;?#28051;被锛屽垎鍒槸A?#25328;B锛孊?#34987;涓?#37722;?#37832;?#28051;涓?#37816;?#37722;慉绫诲?#30789;薄?#27537;寮?#37922;?#38171;岀幇鍦?#37812;?#28000;?#28725;?#28051;?#28051;被杩?#29723;?#28729;炰緥鍖{ A a = new A(); B b = new B(); }锛?#26473;?#37827;跺湪鍐呭瓨涓?#28729;?#38340;?#28051;婂垎閰?#27996;?#28051;?#28051;?#32460;?#38338;?#38171;?#28051;涓?#28699;?#37708;?#28725;硅薄a锛?#28051;涓?#28699;?#37708;?#28725;硅薄b锛屾帴涓?#37833;?#37812;?#28000;?#37807;?#28751;?#28729;?#28000;啓鍏埌纾?#37929;樼殑涓涓?#37826;囦欢涓?#37720;?#38171;?#28751;?#37734;啓鍏?#37826;囦欢鏃跺嚭鐜?#27996;嗛棶棰?#38171;?#37733;?#28051;? 瀵硅薄b鍖?#37722;?#28725;?#28725;硅薄a?#27537;寮?#37922;?#38171;屾墍?#20114;绯?#32513;熶細?#22172;鍔殑灏a?#27537;?#26271;鎹?#28598;嶅埗涓浠藉埌b涓?#38171;?#26473;?#37837;风殑璇濆綋鎴?#28000;?#28000;?#37826;囦欢涓?#37805;?#28598;嶅?#30789;薄?#26882;(涔?#28751;辨槸閲?#37826;?#37716;?#26462;藉埌鍐呭瓨涓??#26882;锛?#37712;呭瓨?#22414;閰?#27996;?#28051;?#28051;? 绌?#38338;?#38171;?#38000;屽?#30789;薄a鍚屾?#36346;湪鍐呭瓨涓?#28699;?#37734;?#28051;?#28000;?#38171;屾兂涓鎯?#37722;?#37835;?#37722;?#38171;屽鏋?#37812;?#37807;?#28103;敼瀵硅薄a?#27537;?#26271;鎹殑璇?#38171;?#38317;?#28051;嶆槸杩?#29781;佹悳绱?#28729;冪殑姣?#28051;浠芥?#30127;鏉?#26440;惧埌瀵硅薄?#26271;鎹殑涓鑷?#37804;?#38171;?#26473;?#28051;嶆槸鎴?#28000;?#37813; 甯?#37832;涚殑锛?/p> <p>?#20114;涓嬪簭鍒?#37718;?#37832;?#37714;剁殑瑙?#37712;?#37826;规锛?/p> <p>1.淇?#28699;樺埌纾?#37929;樼殑鎵鏈夊?#30789;薄閮?#38014;?#23536;?#28051;涓?#25652;?#37714;?#37721;?1, 2, 3绛?#32475;?</p> <p>2.?#32139;瑕佷繚瀛?#28051;涓?#28725;硅薄?#26882;锛屽?#22559;鏌?#29831;?#28725;硅薄?#27128;鍚?#29722;?#28103;?#28699;?#27996;?#37510;?/p> <p>3.濡?#37835;滀互?#22688;淇?#28699;?#26473;?#38171;屽彧?#28214;?#21843;鍏?涓庡凡缁忎繚瀛樼殑鍏?#37832;夊簭鍒?#37721;穢?#27537;瀵硅薄鐩?#37722;??#27537;鏍?#29825;?#38171;?#37722;?#37714;?#38171;屼繚瀛?#29831;?#28725;硅薄</p> <p>閫氳?#22246;互涓婄殑姝?#26976;?#25652;?#37714;?#37718;?#37832;?#37714;?#29785;?#37712;?#27996;嗗?#30789;薄寮?#37922;殑?#26870;棰?#38171;?/p> <p>搴?#37714;?#37718;栫殑瀹?#37916;?#38171;?/p> <p>      灏嗛渶瑕?#29722;?#25652;?#37714;?#37718;栫殑?#34987;瀹?#37916;癝erializable鎺?#37721;?#38171;?#29831;?#37818;?#37721;病鏈夐渶瑕?#28729;?#37916;扮殑鏂规硶锛宨mplements Serializable鍙槸涓?#27996;?#37837;?#23049;?#29831;?#28725;硅薄?#27128;?#24434;琚?#25652;?#37714;?#37718;栫殑锛岀?#36346;悗浣?#37922;?#28051;涓緭鍑?#23092;?濡?#38171;FileOutputStream)鏉?#37835;?#38315;?#28051;涓? ObjectOutputStream(瀵硅薄娴?瀵硅薄锛屾帴?#28483;锛?#28003;?#37922;ObjectOutputStream瀵硅薄?#27537;writeObject(Object obj)鏂规硶灏卞彲?#20114;灏嗗?#20635;暟涓簅bj?#27537;瀵硅薄?#21843;鍑?鍗?#28103;?#28699;?#37711;剁姸鎬?锛?#29781;佹仮澶嶇殑璇?#37714;?#37922;緭鍏?#23092;?#37510;?/p> <p>?#32229;瀛?#38171;?/p> <p>import java.io.*;</p> <p>public class Test <br /> {<br />     public static void main(String[] args) <br />     {<br />         Employee harry = new Employee("Harry Hacker", 50000);<br />         Manager manager1 = new Manager("Tony Tester", 80000);<br />         manager1.setSecretary(harry);<br />         <br />         Employee[] staff = new Employee[2];<br />         <br />         staff[0] = harry;<br />         staff[1] = manager1;<br />         try<br />         {<br />             ObjectOutputStream out = new ObjectOutputStream(<br />                 new FileOutputStream("employee.dat"));<br />             out.writeObject(staff);<br />             out.close();<br />             <br />             ObjectInputStream in = new ObjectInputStream(<br />                 new FileInputStream("employee.dat"));<br />             Employee[] newStaff = (Employee[])in.readObject();<br />             in.close();<br />    <br />             /**<br />              *閫氳繃harry瀵硅薄鏉?#37716;犺柂<br />              *灏?#37734;secretary涓婂弽鏄?#37713;?#37833;?br />              */<br />             newStaff[0].raiseSalary(10);<br />             <br />             for (int i = 0; i < newStaff.length; i++)<br />                 System.out.println(newStaff[i]);<br />         }<br />         catch (Exception e)<br />         {<br />             e.printStackTrace();<br />         }<br />     }<br />     <br /> }</p> <p>class Employee implements Serializable<br /> {<br />     public Employee(String n, double s)<br />     {<br />         name = n;<br />         salary = s;<br />     }<br />     <br />     /**<br />      *鍔犺柂姘?br />      */<br />     public void raiseSalary(double byPercent)<br />     {<br />         double raise = salary * byPercent / 100;<br />         salary += raise;<br />     }<br />     <br />     public String toString()<br />     {<br />         return getClass().getName()<br />             + "[name = "+ name<br />             + ",salary = "+ salary<br />             + "]";<br />     }<br />     <br />     private String name;<br />     private double salary;<br /> }</p> <p>class Manager extends Employee<br /> {<br />     public Manager(String n, double s)<br />     {<br />         super(n, s);<br />         secretary = null;<br />     }<br />     <br />     /**<br />      *璁剧疆绉?#28052;?br />      */<br />     public void setSecretary(Employee s)<br />     {<br />         secretary = s;<br />     }<br />     <br />     public String toString()<br />     {<br />         return super.toString()<br />             + "[secretary = "+ secretary<br />             + "]";<br />     }<br />     <br />     //secretary浠?#29723;?#32457;?#28052;?br />     private Employee secretary; <br /> }</p> <p>淇敼榛?#29825;殑搴?#37714;?#37718;?#37832;?#37714;?#38171;?nbsp;  </p> <p>      鍦? 搴?#37714;?#37718;栫殑杩囩涓?#38171;?#37832;?#27996;涙暟鎹?#28699;楁鎴?#28000;?#28051;?#37807;?#28751;嗗?#36346;簭鍒?#37718;?#38171;屽浜?#23005;?#32491;诲?#26945;鎴?#28000;?#37721;渶瑕?#37734;?#28729;氫?#22795;椂缁?#28729;?#37716;?#28051;妕ransient鍏?#38335;?#28699;?#37719;冲彲锛屽浜transient瀛楁搴? 鍒?#37718;?#37832;?#37714;朵細?#28902;杩?#28051;嶄細灏嗗?#36346;啓鍏?#37826;囦欢锛屽綋?#21159;涔?#28051;嶅彲琚?#37805;?#28598;?#37510;?#28003;?#37832;夋椂鎴?#28000;?#37807;?#28751;嗘煇涓瀛楁搴?#37714;?#37718;?#38171;?#28003;?#28729;?#37734;SDK涓殑瀹氫?#22794;?#23384;槸涓嶅彲搴?#37714;?#37718;栫殑绫诲瀷锛?#26473;?#37837;风殑璇?#37812;?#28000;?#28052;?#36423;?#26916;?#37814;?#28000;? 鏍?#23049;?#28051;簍ransient锛屽彲?#27128;涓嶈兘?#21843;鍏?#37721;?#37804;?#28052;堟仮澶嶅憿锛熷鍦?#25652;?#37714;?#37718;?#37832;?#37714;?#28051;?#37718;?#37722;?#26473;?#32457;嶇?#35268;畩?#26870;棰樼殑?#34987;?#24385;渚?#27996;嗗涓嬬殑鏂规硶瀹氫箟锛?/p> <p>private void readObject(ObjectInputStream in) throws </p> <p>         IOException, ClassNotFoundException;</p> <p>private void writeObject(ObjectOutputStream out) throws</p> <p>         IOException;</p> <p>(娉?#38171;氳繖浜涙?#35268;硶瀹氫箟鏃跺繀椤绘槸绉?#37832;夌殑锛屽洜涓?#28051;嶉渶瑕?#28003;犳?#21095;?#40511;皟鐢?#38171;屽簭鍒?#37718;?#37832;?#37714;朵細?#22172;鍔皟鐢殑)</p> <p>浣?#37922;互涓?#37826;规硶鎴?#28000;彲?#20114;鎵嬪姩瀵?#38317;?#27996;?#28003;犲張鎯?#25652;?#37714;?#37718;?#37721;?#28051;嶅彲?#20114;琚?#25652;?#37714;?#37718;栫殑?#26271;鎹?#28699;楁杩?#29723;屽啓鍑哄拰璇诲叆鎿?#28003;?#37510;?/p> <p>      涓?#38344;槸涓涓?#37711;稿?#23340;殑?#32229;瀛?#38171;宩ava.awt.geom鍖?#28051;殑Point2D.Double?#34987;灏辨槸涓嶅彲搴?#37714;?#37718;栫殑锛屽洜涓?#29831;被?#30149;鏈?#28729;?#37916;癝erializable鎺?#37721;?#38171;?#37734;?#37812;戠殑?#32229;瀛?#28051;?#28751;?#37814;?#28729;冨綋浣LabeledPoint?#34987;涓殑涓涓暟鎹?#28699;楁锛?#39582;舵紨绀?#28641;?#28003;?#28751;嗗?#36346;簭鍒?#37718;?#38171;?/p> <p>import java.io.*;<br /> import java.awt.geom.*;</p> <p>public class TransientTest <br /> {<br />     public static void main(String[] args) <br />     {<br />         LabeledPoint label = new LabeledPoint("Book", 5.00, 5.00);<br />         try<br />         {<br />             System.out.println(label);//?#21843;鍏墠<br />             ObjectOutputStream out = new ObjectOutputStream(new<br />                 FileOutputStream("Label.txt"));<br />             out.writeObject(label);<br />             out.close();<br />             <br />             System.out.println(label);//?#21843;鍏?#37722;?br />             <br />             ObjectInputStream in = new ObjectInputStream(new<br />                 FileInputStream("Label.txt"));<br />             LabeledPoint label1 = (LabeledPoint)in.readObject();<br />             in.close();<br />             System.out.println(label1);//璇?#37713;?#39582;跺姞1.0鍚?br />         }<br />         catch (Exception e)<br />         {<br />             e.printStackTrace();<br />         }<br />     }<br />     <br /> }</p> <p>class LabeledPoint implements Serializable<br /> {<br />     public LabeledPoint(String str, double x, double y)<br />     {<br />         label = str;<br />         point = new Point2D.Double(x, y);<br />     }<br />     <br />     private void writeObject(ObjectOutputStream out) throws IOException<br />     {<br />         /**<br />          *蹇?#26916;?#38315;氳繃?#30367;鐢defaultWriteObject()鏂规硶鏉啓鍏?br />          *瀵硅薄?#27537;鎻忚?#39041;互鍙?#38317;?#27996;涘彲?#20114;琚?#25652;?#37714;?#37718;栫殑瀛楁<br />          */<br />         out.defaultWriteObject();<br />         out.writeDouble(point.getX());<br />         out.writeDouble(point.getY());<br />     }<br />     <br />     private void readObject(ObjectInputStream in)<br />         throws IOException, ClassNotFoundException<br />     {<br />         /**<br />          *蹇?#26916;昏皟鐢defaultReadObject()鏂规硶<br />          */<br />         in.defaultReadObject();<br />         double x = in.readDouble() + 1.0;<br />         double y = in.readDouble() + 1.0;<br />         point = new Point2D.Double(x, y);<br />     }<br />     <br />     public String toString()<br />     {<br />         return getClass().getName()<br />             + "[label = "+ label<br />             + ", point.getX() = "+ point.getX()<br />             + ", point.getY() = "+ point.getY()<br />             + "]";<br />     }<br />     <br />     private  String label;<br />     transient private Point2D.Double point;<br /> }<br />  </p> <p> </p> </span> <br /> <div style="font-size: 14px; line-height: 25px;"><strong>浣?#38000;匓log锛?/strong><a id="ArticleContent1_ArticleContent1_AuthorBlogLink" href="http://blog.csdn.net/hdAptechIvan/" target="_blank">http://blog.csdn.net/hdAptechIvan/</a></div> <img src ="http://www.67529968.com/caizh2009/aggbug/342921.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/caizh2009/" target="_blank">灏忚彍姣?#23011;?/a> 2011-01-13 13:29 <a href="http://www.67529968.com/caizh2009/archive/2011/01/13/342921.html#Feedback" target="_blank" style="text-decoration:none;">鍙?#29723;?#29831;勮</a></div>]]></description></item><item><title>Android鑾峰彇Contact Number?#27537;?#32229;瀛?#38171;?.0绯?#32513;熶互鍓嶇殑鑾峰彇鏂?#23534;?#38171;?/title><link>http://www.67529968.com/caizh2009/archive/2010/12/17/341010.html</link><dc:creator>灏忚彍姣?#23011;?/dc:creator><author>灏忚彍姣?#23011;?/author><pubDate>Fri, 17 Dec 2010 09:45:00 GMT</pubDate><guid>http://www.67529968.com/caizh2009/archive/2010/12/17/341010.html</guid><wfw:comment>http://www.67529968.com/caizh2009/comments/341010.html</wfw:comment><comments>http://www.67529968.com/caizh2009/archive/2010/12/17/341010.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.67529968.com/caizh2009/comments/commentRss/341010.html</wfw:commentRss><trackback:ping>http://www.67529968.com/caizh2009/services/trackbacks/341010.html</trackback:ping><description><![CDATA[<ol class="dp-j" start="1"> <li>String[] projection = <span class="keyword">new String[] {  </span></li> <li>People._ID,  </li> <li>People.NAME,  </li> <li>People.NUMBER,  </li> <li>};  </li> <li>  </li> <li><span class="comment">// Get the base URI for People table in Contacts content provider.  </span></li> <li><span class="comment">// which is: content://contacts/people/  </span></li> <li>Uri contactUri = People.CONTENT_URI;  </li> <li>  </li> <li><span class="comment">// Best way to retrieve a query; returns a managed query.  </span></li> <li>Cursor peopleCursor = managedQuery (contactUri,  </li> <li>projection, <span class="comment">//Which columns to return.  </span></li> <li><span class="keyword">null, <span class="comment">// WHERE clause--we won't specify.</span>  </span></li> <li><span class="keyword">null, <span class="comment">// Selection Args??</span>  </span></li> <li>People.DEFAULT_SORT_ORDER); <span class="comment">// Order-by name  </span></li> <li>  </li> <li><span class="comment">// go to the beginning of the list  </span></li> <li>peopleCursor.moveToFirst();  </li> <li>  </li> <li>  </li> <li><span class="comment">// So, here we have a contact. We need to get the contact ID (_id) then  </span></li> <li><span class="comment">// build the Uri to get the phones section of that user's record  </span></li> <li><span class="comment">// which is a subdirectory of a contact record  </span></li> <li>  </li> <li><span class="keyword">long personId = peopleCursor.getLong(peopleCursor.getColumnIndex(<span class="string">"_id"</span>));  </span></li> <li>  </li> <li>Uri personUri = ContentUris.withAppendedId(contactUri, personId );  </li> <li>  </li> <li><span class="comment">// So now the URL looks like: content://contacts/people/_id(where the actual id of the record is here)  </span></li> <li>Uri phoneUri=  </li> <li>Uri.withAppendedPath(personUri, Contacts.People.Phones.CONTENT_DIRECTORY);  </li> <li>  </li> <li><span class="comment">// Now the URL looks like: content://contacts/people/_id/phones (where phones is literally "phones")  </span></li> <li>  </li> <li><span class="comment">// Now get all the phone numbers for this contact  </span></li> <li>Cursor phonesCursor = managedQuery(phoneUri,  </li> <li><span class="keyword">null,  </span></li> <li><span class="keyword">null,  </span></li> <li><span class="keyword">null,  </span></li> <li>Phones.DEFAULT_SORT_ORDER);  </li> <li>  </li> <li><span class="comment">// We now have a cursor for all the phone numbers for that User ID  </span></li> <li><span class="comment">// go to the beginning of the phone list.  </span></li> <li>phonesCursor.moveToFirst();   </li> </ol> <img src ="http://www.67529968.com/caizh2009/aggbug/341010.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/caizh2009/" target="_blank">灏忚彍姣?#23011;?/a> 2010-12-17 17:45 <a href="http://www.67529968.com/caizh2009/archive/2010/12/17/341010.html#Feedback" target="_blank" style="text-decoration:none;">鍙?#29723;?#29831;勮</a></div>]]></description></item><item><title>android 2.2 鑾峰彇鑱?#32495;?#27996;?#38171;?#37922;?#29831;?#38171;?#39582;舵嫧鍙?/title><link>http://www.67529968.com/caizh2009/archive/2010/12/17/341002.html</link><dc:creator>灏忚彍姣?#23011;?/dc:creator><author>灏忚彍姣?#23011;?/author><pubDate>Fri, 17 Dec 2010 08:58:00 GMT</pubDate><guid>http://www.67529968.com/caizh2009/archive/2010/12/17/341002.html</guid><wfw:comment>http://www.67529968.com/caizh2009/comments/341002.html</wfw:comment><comments>http://www.67529968.com/caizh2009/archive/2010/12/17/341002.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.67529968.com/caizh2009/comments/commentRss/341002.html</wfw:commentRss><trackback:ping>http://www.67529968.com/caizh2009/services/trackbacks/341002.html</trackback:ping><description><![CDATA[<h1 class="title_txt" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0.5em; padding-left: 1.5em; font-size: 15px; font-family: 'Microsoft yahei', verdana, sans-serif; border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: #dcdcdc; line-height: 18px; "><img src="http://blog.csdn.net/images/authorship.gif" border="0" width="15" height="15" alt="?#24107;鍒? style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: -20px; " />  android 2.2 鑾峰彇鑱?#32495;?#27996;?#38171;?#37922;?#29831;?#38171;?#39582;舵嫧鍙?nbsp;<cite class="fav_csdnstylebykimi" style="font-style: normal; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 5px; display: inline; text-decoration: none; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://blog.csdn.net/happyhell/archive/2010/07/05/5714108.aspx" class="fav_csdnstylebykimi" title="鏀惰?#24531;埌鎴戠殑缃戞憳涓?#38171;?#39582;跺垎浜?#32513;欐垜?#27537;鏈嬪" style="text-decoration: none; color: #336699; font: normal normal normal 12px/normal Tahoma, sans-serif; padding-top: 1px; padding-right: 25px; padding-bottom: 1px; padding-left: 10px; background-image: url(http://blog.csdn.net/images/share-add.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0px 0px; background-repeat: no-repeat no-repeat; ">鏀惰棌</a></cite></h1> <div class="blogstory" style="float: left; width: 923px; font-size: 14px; line-height: 21px; font-family: verdana, sans-serif; "> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">璇demo?#27128;绗?#28051;娆熀浜巃ndroid寮鍙?#37510;?/p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">涓?#29781;?#37716;?#38003;?#37832;?#38171;?璇诲彇鑱?#32495;?#27996;?#28654;?#37722;?#37510;?#37721;风爜锛?#39582;秎isetview 鏄剧锛?#38014;峰彇listview?#26271;鎹?#38171;?#39582;跺?#25120;煭淇?#37510;?#37812;?#38000;呮嫧鍙?/p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">package com.android.hello;</p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">import android.app.Activity;<br /> import android.content.Intent;   <br /> import android.database.Cursor;<br /> import android.graphics.Color;   <br /> import android.net.Uri;   <br /> import android.os.Bundle; <br /> import android.telephony.PhoneNumberUtils; <br /> import android.util.Log;   <br /> import android.view.View;   <br /> import android.widget.AdapterView;   <br /> import android.widget.LinearLayout;   <br /> import android.widget.ListAdapter;   <br /> import android.widget.ListView;<br /> import android.widget.RelativeLayout;<br /> import android.widget.TextView;<br /> import android.widget.Toast; <br /> import android.provider.ContactsContract;</p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">import java.util.ArrayList;   <br /> import java.util.HashMap;<br /> import android.widget.SimpleAdapter;</p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">@SuppressWarnings("deprecation")<br /> public class hello extends Activity {<br />     /** Called when the activity is first created. */<br />    // @SuppressWarnings("deprecation")<br /> // @Override<br />  //  <br />  private static final String TAG="App";   <br />     ListView listView;   <br />     ListAdapter adapter;   <br />     /** Called when the activity is first created. */  <br />     @Override  <br />     public void onCreate(Bundle savedInstanceState) {   <br />         super.onCreate(savedInstanceState);   <br />        // setContentView(R.layout.main);   <br />         LinearLayout linearLayout=new LinearLayout(this);   <br />         linearLayout.setOrientation(LinearLayout.VERTICAL);   <br />         linearLayout.setBackgroundColor(Color.BLACK);   <br />         LinearLayout.LayoutParams param=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);   <br />            <br />         listView=new ListView(this);   <br />         listView.setBackgroundColor(Color.BLACK);   <br />            <br />         linearLayout.addView(listView,param);   <br />            <br />         this.setContentView(linearLayout);   <br />            <br />      <br />       //鐢熸垚鍔?#37804;佹暟缁?#38171;?#37716;犲叆?#26271;鎹?br />         ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();        <br />         ArrayList<HashMap<String, Object>> listItemRead = new ArrayList<HashMap<String, Object>>();     <br />         Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);      <br />         while (cursor.moveToNext())    <br />         {     <br />          HashMap<String, Object> map = new HashMap<String, Object>();<br />          String phoneName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));<br />          map.put("ItemTitle", phoneName);//鐢?#29831;?#28654;?#37722;?br />          String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));   <br />             String hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));   <br />             <br />             if (hasPhone.compareTo("1") == 0)    <br />             {   <br />                 Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,null, null);        <br />                 while (phones.moveToNext())    <br />                 {      <br />                  String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));       <br />                     String phoneTpye = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));       <br />                    <br />                     map.put("ItemText", phoneNumber); // 澶?#28051;?#37721;风爜濡?#28003;?#28598;?#37918;?br />                     <br />                     Log.d(TAG,"testNum="+ phoneNumber + "type:"+phoneTpye); <br />                 }        <br />                 phones.close();       <br />             }       <br />             Cursor emails = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,null,ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId,null, null);   <br />             while (emails.moveToNext())    <br />             {                    <br />                 String emailAddress = emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));   <br />                 String emailType = emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));      </p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">                Log.d(TAG,"testNum="+ emailAddress + "type:"+emailType); <br />             }       <br />             emails.close();<br />             <br />             listItem.add(map); <br />         }<br />         <br />         //鐢熸垚閫?#38320;嶅櫒?#27537;Item?#25328;鍔?#37804;佹暟缁勫搴旂殑?#21395;绱?nbsp;  <br />         SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,//?#26271;鎹簮    <br />             android.R.layout.simple_list_item_2,//ListItem?#27537;XML瀹?#37916;?nbsp;  <br />             //鍔?#37804;佹暟缁?#28051;ImageItem瀵?#25652;旂殑瀛?#26916;?nbsp;          <br />             new String[] {"ItemTitle", "ItemText"},    <br />             //ImageItem?#27537;XML鏂囦欢閲?#38344;殑涓涓狪mageView,涓?#28051;猅extView ID   <br />             new int[] {android.R.id.text1,android.R.id.text2}   <br />         );              <br />         <br />         listView.setAdapter(listItemAdapter);   <br />         cursor.close();  <br />         <br />         //listView.setEmptyView(findViewById(R.id.empty));   <br />            <br />         listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){   <br />   <br />             public void onItemSelected(AdapterView<?> arg0, View arg1,   <br />                     int arg2, long arg3) {   <br />                 // TODO Auto-generated method stub   <br />                 //openToast("婊氬姩?#22476;锛?+arg0.getSelectedItemId());   <br />                 //鐭?#28103;?#37721;?#38315;?nbsp;  <br />              setTitle("閫夋嫨"+arg2+"椤圭洰");<br />              openToast("閫夋嫨"+arg0.getSelectedItemId()+"椤圭洰");<br />     RelativeLayout lr = (RelativeLayout) arg1;<br />     TextView mText = (TextView) lr.getChildAt(1);<br />     openToast(mText.getText().toString());</p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">    String number = mText.getText().toString();<br />     Log.d(TAG, "number=" + number);<br />     // 鍒?#37826;?#37922;?#29831;濆?#39118;爜?#27537;鏈夋晥鎬?br />     if (PhoneNumberUtils.isGlobalPhoneNumber(number)) {<br />      Intent intent = new Intent(Intent.ACTION_SENDTO, Uri<br />        .parse("smsto://" + number));<br />      intent.putExtra("sms_body", "The SMS text");<br />      startActivity(intent);             <br />     } <br />             }   <br />   <br />             public void onNothingSelected(AdapterView<?> arg0) {   <br />                 // TODO Auto-generated method stub   <br />                    <br />             }   <br />                <br />         });  <br />         <br />         listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){  </p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">   public void onItemClick(AdapterView<?> arg0, View arg1,<br />      int position, long arg3) {<br />     // TODO Auto-generated method stub<br />     // openToast("Click"+Integer.toString(position+1)+"椤圭洰");<br />     RelativeLayout lr = (RelativeLayout) arg1;<br />     TextView mText = (TextView) lr.getChildAt(1);<br />     openToast(mText.getText().toString());</p> <p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; ">    String number = mText.getText().toString();<br />     Log.d(TAG, "number=" + number);<br />     // 鍒?#37826;?#37922;?#29831;濆?#39118;爜?#27537;鏈夋晥鎬?br />     if (PhoneNumberUtils.isGlobalPhoneNumber(number)) {<br />      Intent intent = new Intent(Intent.ACTION_DIAL, Uri<br />        .parse("tel://" + number));<br />      startActivity(intent);<br />     }<br />    }<br />   });<br />  }<br />  <br />     private void openToast(String str){   <br />         Toast.makeText(this,str,Toast.LENGTH_SHORT).show();   <br />     }   <br /> } </p> </div> <img src ="http://www.67529968.com/caizh2009/aggbug/341002.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/caizh2009/" target="_blank">灏忚彍姣?#23011;?/a> 2010-12-17 16:58 <a href="http://www.67529968.com/caizh2009/archive/2010/12/17/341002.html#Feedback" target="_blank" style="text-decoration:none;">鍙?#29723;?#29831;勮</a></div>]]></description></item><item><title>java涓?#37826;囨?#22794;?#26945;帓搴?/title><link>http://www.67529968.com/caizh2009/archive/2010/12/17/340974.html</link><dc:creator>灏忚彍姣?#23011;?/dc:creator><author>灏忚彍姣?#23011;?/author><pubDate>Fri, 17 Dec 2010 05:22:00 GMT</pubDate><guid>http://www.67529968.com/caizh2009/archive/2010/12/17/340974.html</guid><wfw:comment>http://www.67529968.com/caizh2009/comments/340974.html</wfw:comment><comments>http://www.67529968.com/caizh2009/archive/2010/12/17/340974.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.67529968.com/caizh2009/comments/commentRss/340974.html</wfw:commentRss><trackback:ping>http://www.67529968.com/caizh2009/services/trackbacks/340974.html</trackback:ping><description><![CDATA[<p><span style="color: #808080;"><span style="color: #00ff00;"><span style="color: #339966;">// Collator ?#34987;?#27128;鐢?#37833;?#37813;?#29723;屽尯?#22414;璇?#29815;?#24134;澧冪殑 String 姣?#26440;冪殑锛?#26473;?#38322;?#38315;夋嫨浣?#37922;CHINA   </span>  </span>    </span> </p> <p><span style="color: #ff6600;"> Comparator cmp = Collator.getInstance(java.util.Locale.CHINA); </span> </p> <p><span style="color: #ff6600;">TreeMap tree=new TreeMap(cmp);</span> <span style="color: #808080;"><span style="color: #ff6600;">     </span> <br /> </span> </p> <p><span style="color: #808080;"><span style="color: #ff6600;">  String[] arr = {"寮?#28051;?, "鏉庡洓", "鐜?#27996;?};   </span>     </span> </p> <p><span style="color: #808080;"><span style="color: #339966;">// 浣?#37837;规嵁鎸?#28729;?#23011;?#26440;冨櫒浜?#37922;熺殑椤?#25652;?#28725;规寚瀹氬?#30789;薄?#26271;缁?#26473;?#29723;屾帓搴?#37510;?nbsp;</span>     </span> </p> <p><span style="color: #ff6600;">   Arrays.sort(arr, cmp);      </span> </p> <p><span style="color: #ff6600;">  for (int i = 0; i < arr.length; i++)         </span> </p> <p><span style="color: #ff6600;">    System.out.println(arr[i]);</span> </p> <p> </p> <p> </p> <p><span style="color: #808080;"> </span></p> <p><script><br />  names = ["寮?#28051;?, "鏉庡洓", "鐜?#27996;?, "鍒?#37711;?];<br />  names.sort(function(a,b){return a.localeCompare(b)});//a,b 涓烘暟缁刟?#27537;鏌?#28051;?#28051;?#37706;?#38171;岃嚜鍔?#28028;犲叆<br />  alert(names);<br /> </script></p> <p> </p> <p>鍙?</p> <p> </p> <h4>绀轰緥鏂?#37832;?#38171;?/h4> <p><br /> <strong><br /> String [] test = new String[] {<br />                 "浣?#28051;?,<br />                 "娴嬭瘯",<br />                 "test",<br />                 "鎴?#28000;?,<br />                 "銆傜",<br />                 "闀傜",<br />                 "[",<br />                 "娴?,<br />                 "鐨?<br />         };<br /> </strong> </p> <h4>jdk 鐗?#37832;?#38171;?/h4> <p> 1.5.6</p> <h4>寮鍙?#39582;?#37721;?#38171;?/h4> <p> Eclipse 3.1</p> <h4>鍏?#38335;?#28699;?#38171;?nbsp;涓?#37826;?#37818;?#25652;?/h4> <p> </p> <h3>姒?#26473;?/h3> <p><br /> 鎴?#28000;?#37734;?#25652;?#37922;?#32459;嬪簭涓彲鑳戒細缁忓父?#20131;?#22476;瀵?#28051;?#37826;?#37818;?#25652;忕殑?#26870;棰?#38171;屼緥濡?#28654;?#37722;嶅垪琛?#38171;?#29831;嶆琛?#32475;?#32475;?#37510;?#28725;?#28051;?#37826;?#37818;?#25652;?#38171;屾垜浠?#28003;?#37922;?#23011;?#26440;?#28598;氱殑?#27128;鏍规嵁姹?#29831;?#37815;奸煶鍙戦煶鏉?#32429;?#28729;?#26916;?#25652;?#37510;?br /> <br /> 鎴?#28000;彲鑳戒細缁忓父浣?#37922;?nbsp; </p> <div class="codeStyle"> <ol> <li>java.util.<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/util/Set.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Set</span> </span> </a> </strong> </li> </ol> </div> <p> 鎺?#37721;?#38171;?</p> <div class="codeStyle"> <ol> <li>java.util.<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/util/Arrays.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Arrays</span> </span> </a> </strong> .sort((T[] a, <span style="color: #ff0000;">Comparator</span> <? <strong><span style="color: #0000ff;">super</span> </strong>  T> c)) </li> </ol> </div> <p> 绛夌被鎴?#37826;规硶瀵?#37722;?#37832;?#28051;?#37826;?#28699;?#32471;殑瀵硅薄杩?#29723;屾帓搴?#38171;?#28003;嗘槸杩?#27996;?#37734;?#27035;?#29825;?#37807;?#37712;?#28051;?#38318;芥槸?#30367;鐢?nbsp; </p> <div class="codeStyle"> <ol> <li><strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong> .CompareTo(<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong> ) </li> </ol> </div> <p>鏂规硶锛?#26473;?#28051;?#37826;规硶?#27128;姣?#26440;?涓?#28699;?#32471;殑 codepoint value锛屽鏋?#32471;?#28051;涓?#28699;?#32471;殑鍊?#28751;?#27996;?#32471;?#27996;?#28051;?#38171;?#37714;?#37734;?#37818;?#25652;?#32513;?#37835;?#28051;?#32471;?#28051;涓細鍦墠闈?#38171;屽弽涔?#27996;劧銆?/p> <h3> <div class="codeStyle"> <ol> <li>java.text.<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/Collator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Collator</span> </span> </a> </strong> </li> </ol> </div> 鎺?#37721;?#37721;婂叾瀹?#37916;扮被</h3> <p><br /> 鍏?#28729;?nbsp;java 涓彁渚?#27996;嗗拰璇?#29815;鐩?#37711;崇殑?#34987;锛屽嵆 Collator 鎺?#37721;?#37721;婂叾瀹?#37916;扮被銆?</p> <div class="codeStyle"> <ol> <li>java.text.<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong> </li> </ol> </div> <p> ?#27128;涓涓?#37711;蜂綋?#34987;锛?#28729;?#28729;?#37916;?#27996;?nbsp;Comparator 鎺?#37721;?#28051;殑 compare(Object, Object) 鏂规硶銆? RuleBasedCollator 鏍规嵁鏍规嵁鐗?#28729;氳瑷?#27537;榛?#29825;?#29785;?#37714;?#23011;?#26440;?#28699;?#32471;?#38171;?#28052;熷彲?#20114;鎸夌収鎸?#28729;氱殑瑙?#37714;?#37833;?#23011;?#26440;?#38171;?#29831;峰?#20638; java API 鑾峰彇姝被?#27537;璇?#32513;嗕俊 ?#20229;銆?br /> 濡?#37835;?#37812;?#28000;渶瑕?#28725;?#28051;涓?#37832;?#28051;?#37826;囩殑?#26271;缁?#26473;?#29723;屾帓搴?#38171;?#37714;欏彲?#20114;浣?#37922;?#26473;?#28051;被銆?#29831;?#37930;嬪涓?#32448;轰緥浠爜锛?/p> <div class="codeStyle"> <ol> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.util.*; </li> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.text.*; </li> <li><strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">class</span> </strong>  Test </li> <li>{ </li> <li>        <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  [] test = <strong><span style="color: #0000ff;">new</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong> [] { </li> <li>                <span style="color: #ff33ff;">"浣?#28051;?</span> , </li> <li>                <span style="color: #ff33ff;">"娴嬭瘯"</span> , </li> <li>                <span style="color: #ff33ff;">"test"</span> , </li> <li>                <span style="color: #ff33ff;">"鎴?#28000;?</span> , </li> <li>                <span style="color: #ff33ff;">"銆傜"</span> , </li> <li>                <span style="color: #ff33ff;">"闀傜"</span> , </li> <li>                <span style="color: #ff33ff;">"["</span> , </li> <li>                <span style="color: #ff33ff;">"娴?</span> , </li> <li>                <span style="color: #ff33ff;">"鐨?</span> </li> <li>        }; </li> <li>      java.util.<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/util/Arrays.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Arrays</span> </span> </a> </strong> .sort(test,  </li> <li>              (<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong> )<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/Collator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Collator</span> </span> </a> </strong> .getInstance(<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/util/Locale.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Locale</span> </span> </a> </strong> .CHINA)); </li> <li>      <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/System.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">System</span> </span> </a> </strong> .out.println(<span style="color: #ff33ff;">"============"</span> ); </li> <li>      <strong><span style="color: #0000ff;">for</span> </strong> (<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  key : test) </li> <li>          <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/System.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">System</span> </span> </a> </strong> .out.println(key); </li> <li>} </li> </ol> </div> <p><br /> <br /> ?#20114;涓?#28000;爜?#27537;?#32237;鍑?#32513;?#37835;?#28051;?#38171;?br /> <strong><br /> ============<br /> [<br /> test<br /> 銆傜<br /> 娴嬭瘯<br /> 鎴?#28000;?br /> 浣?#28051;?br /> 娴?br /> 闀傜<br /> 鐨?br /> </strong> <br /> <br /> 澶?#28729;跺彲鑳戒細鍙?#37916;?#37721;?#37832;?#28051;閮垎姹夊?#26945;槸鎸夌収姹?#29831;?#37815;奸?#34411;帓搴?#27996;?#38171;?#26473;?#37832;?#37713;?#28051;病鏈?#37510;?/p> <h3>?#26870;棰樺垎?#28733;锛?/h3> <p><br /> GB2312:<br /> 鍦?#32480;?#32139;涓?#37826;?#28051;?#37812;?#28000;?#28003;?#37922;?#23011;?#26440;?#28598;氱殑瀛?#32471;?#38342;嗘槸 GB2312-80锛?#32480;绉?#28051;?nbsp;GB2312锛?#26473;?#28051;?#28699;?#32471;泦鍖?#37722;?#27996;嗙洰?#22688;鏈?#29238;鐢殑姹夊瓧?#21473;璁?nbsp;6736 涓?#37510;?#37711;?#28051;殑姹夊瓧?#22414;涓?#28051;?#28598;被锛?/p> <ul> ?#29238;鐢?#23033;夊瓧 </ul> <p> </p> <ul> 娆父鐢?#23033;夊瓧 </ul> <p><br /> <br /> ?#29238;鐢?#23033;夊?#26945;?#22796;収姹?#29831;?#37815;奸煶鏉?#37818;?#25652;?#38171;?#38000;屾?#29238;鐢?#23033;夊?#26945;?#22796;収绗?#37922;?#38318;?#26851;?#26473;?#29723;屾帓搴?#37510;?br /> <br /> 绠?#32139;姹夊瓧鍦?nbsp;Unicode 涓?#28051;鑸槸鎸夌収 gb2312 ?#27537;?#29212;?#20579;鍊肩殑椤?#25652;?#37833;斁?#30086;?#27537;锛屾墍?#20114;濡?#37835;滄槸?#29238;鐢?#23033;夊瓧 java 灏?#38003;?#28598;?#23536;?#37713;?#32429;殑杩?#29723;屾帓搴?#38171;?#28003;嗗鏋滄槸娆父鐢?#23033;夊瓧锛?#37714;?#28751;变細鍑?#37916;伴棶棰樸?#37734;互涓?#32448;轰緥涓?#38171;?闀?锛?鐨? ?#30552;浜?#23046;父鐢?#28699;?#37510;?/p> <h3>瑙?#37712;?#37826;规锛?/h3> <p><br /> RuleBasedCollator ?#34987; getRules() 鏂规硶?#24434;?#20114;杩?#37733;?#28725;?#25652;?#29831;?#29815;?#27537;瑙?#37714;欒?#21095;疆銆傜畝?#32139;涓?#37826;?#28725;?#25652;旂殑瑙?#37714;欐槸 gb2312 鎵瀵?#25652;旂殑瀛?#32471;?#37510;?/p> <ol><br /> 鎴?#28000;彲?#20114;鎶婂叾涓殑鍏?#38318;?#23033;夊?#26945;?#24876;彇鍑?#37833;?/ol> <p> </p> <ol>瀵?#26473;?#27996;涙?#22794;瓧閲?#37826;版帓搴?/ol> <p> </p> <ol>鍒?#37922;RuleBasedCollator(String rules) 鏋?#38315;犲櫒鏂板缓涓涓?#28729;?#37714;剁殑 RuleBasedCollator</ol> <p> </p> <h3>鍙?#38000;?#28000;爜</h3> <p><br /> 鍦互涓嬬殑浠爜涓?#38171;屾垜鎶?#37818;?#26473;?#25652;忕殑姹夊瓧鐩存帴浣?#28051;?nbsp;String 瀵硅薄?#25985;鍦被閲?#38344;?#27996;?#38171;屽鏋?#29781;?#29825;?#28000;爜鍙?#23536;?#32480;娲?#28051;浜?#38171;?#37714;欏彲?#20114;鎶?#28729;屾暣?#27537;瑙?#37714;?#38171;?#37911;规?#23106;瓧绗?#38171;嬫帓搴忔?#22794;瓧锛夊瓨涓?#37826;囦欢銆?/p> <div class="codeStyle"> <ol> <li><strong><span style="color: #0000ff;">package</span> </strong>  sorting; </li> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.util.*; </li> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.text.*; </li> <li><em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;"> * @author GaoJianMin</span> </em> </li> <li><em><span style="color: #339900;"> *</span> </em> </li> <li><em><span style="color: #339900;"> */</span> </em> </li> <li><strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">class</span> </strong>  ChineseGB2312Collator </li> <li>{ </li> <li>    <em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;">     * @return a customized RuleBasedCollator with Chinese characters (GB2312) sorted correctly</span> </em> </li> <li><em><span style="color: #339900;">     * </span> </em> </li> <li><em><span style="color: #339900;">     */</span> </em> </li> <li>    <strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">static</span> </strong>  <strong><span style="color: #0000ff;">final</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong>  getFixedGB2312Collator() </li> <li>    { </li> <li>        <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong>  fixedGB2312Collator =<strong><span style="color: #0000ff;">null</span> </strong> ; </li> <li>        <strong><span style="color: #0000ff;">try</span> </strong> </li> <li>        { </li> <li>            fixedGB2312Collator = <strong><span style="color: #0000ff;">new</span> </strong>  java.text.<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong> ( </li> <li>                    ChineseGB2312Collator.getGB2312SpecialChars() + </li> <li>                    GB2312Chars </li> <li>                    ); </li> <li>        }<strong><span style="color: #0000ff;">catch</span> </strong> (<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/ParseException.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">ParseException</span> </span> </a> </strong>  e) </li> <li>        { </li> <li>            e.printStackTrace(); </li> <li>        } </li> <li>        <strong><span style="color: #0000ff;">return</span> </strong>  fixedGB2312Collator; </li> <li>    } </li> <li>     </li> <li>    <em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;">     * @return the special characters in GB2312 charset.</span> </em> </li> <li><em><span style="color: #339900;">     * </span> </em> </li> <li><em><span style="color: #339900;">     */</span> </em> </li> <li>    <strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">static</span> </strong>  <strong><span style="color: #0000ff;">final</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  getGB2312SpecialChars() </li> <li>    { </li> <li>        <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong>  zh_CNCollator = (<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong> )<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/Collator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Collator</span> </span> </a> </strong> .getInstance(<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/util/Locale.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Locale</span> </span> </a> </strong> .CHINA); </li> <li>        <em><span style="color: #339900;">//index 2125 is the last symbol "鈺?</span> </em> </li> <li>        <strong><span style="color: #0000ff;">return</span> </strong>  zh_CNCollator.getRules().substring(0,2125); </li> <li>    } </li> <li>     </li> <li>    <em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;">     * 6763 Chinese characters in GB2312 charset</span> </em> </li> <li><em><span style="color: #339900;">     */</span> </em> </li> <li>    <strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">static</span> </strong>  <strong><span style="color: #0000ff;">final</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  GB2312Chars = </li> <li>        <span style="color: #ff33ff;">"<鍚?lt;闃?lt;鍟?lt; 閿?lt;鍡?lt;鍝?lt;鍝<鍞?lt;鍩?lt;鎸?lt;閿?lt;鎹?lt;鐨?lt;鐧?lt;鍡?lt;鐭?lt;钄?lt; 闇?lt;?#22744;<鐖?lt;鐮?lt;闅?lt;鍡?lt;瀚?lt;纰?lt;鏆?lt;鐟?lt;瀹?lt;妗?lt;姘?lt;搴?lt; 璋?lt;楣?lt;闉?lt;淇?lt;鍩?lt;閾?lt;鎻?lt;鐘?lt;宀?lt;鎸?lt;妗?lt;鑳?lt;鏆?lt;榛?lt; 鑲?lt;鏄?lt;鐩?lt;鍑?lt;鍧?lt;鏁?lt;鍡?lt;寤?lt;鐛?lt;閬?lt;鐔?lt;缈?lt;鑱?lt;铻?lt; 槌?lt;?#24391;<鎷?lt;琚?lt;濯?lt;宀?lt;鍌?lt;濂?lt;楠?lt;婢?lt;?#22132;<?#24375;"</span>  + </li> <li>        <span style="color: #ff33ff;">"<鍏?lt;宸?lt;鍙?lt; 鎵?lt;鍚?lt;宀?lt;鑺?lt;鐤?lt;鎹?lt;绗?lt;绮?lt;鎷?lt;?#23514;<鑿?lt;璺?lt;榄?lt;鎶?lt; 閽?lt;闈?lt;鍧?lt;鐖?lt;缃?lt;椴?lt;闇?lt;鐏?lt;?#24135;<鐧?lt;鐧?lt;浣?lt;鏌?lt;鎹?lt; 鎽?lt;鍛?lt;璐?lt;鎷?lt;绋?lt;鎵?lt;鐝?lt;鑸?lt;棰?lt;鏂?lt;鎼?lt;鐦?lt;鐧?lt;闃?lt; ?#28485;<鏉?lt;鐗?lt;閽?lt;鑸?lt;鍔?lt;鍗?lt;浼?lt;鎵?lt;鎷?lt;缁?lt;鐡?lt;閭?lt;甯?lt; 姊?lt;娴?lt;缁?lt;姒?lt;鑶<铓?lt;鍌?lt;妫?lt;璋?lt;钂?lt;纾?lt;闀?lt;鍕?lt;鍖?lt; 瀛?lt;鑻?lt;鑳?lt;鐓?lt;榫?lt;瑜?lt;闆?lt;瀹?lt;楗?lt;淇?lt;楦?lt;鍫?lt;钁?lt;瑜?lt; 鎶?lt;鎶?lt;璞?lt;瓒?lt;椴?lt;鏆?lt;?#22414;<闄?lt;鍗?lt;鏉?lt;鎮?lt;纰?lt;楣?lt;鍖?lt; 璐?lt;鐙?lt;閭?lt;澶?lt;鑳?lt;閽?lt;鍊?lt;鎮?lt;琚?lt;鎯?lt;鐒?lt;杈?lt;纰?lt;钃?lt; 瑜?lt;闉?lt;閻?lt;濂?lt;璐?lt;閿?lt;鏈?lt;鑻?lt;鐣?lt;鍧?lt;绗?lt;宕?lt;缁?lt;鍢?lt; 鐢?lt;娉?lt;杩?lt;鐢?lt;?#21151;<閫?lt;鑽?lt;榧?lt;鍖?lt;姣?lt;鍚?lt;濡?lt;褰?lt;绉?lt; 淇?lt;绗?lt;鑸?lt;閯?lt;甯?lt;蹇?lt;姣?lt;闂?lt;搴?lt;鐣<鍝?lt;姣?lt;鑽?lt;闄?lt; 姣?lt;鐙?lt;閾?lt;濠?lt;搴?lt;鏁?lt;?#24714;<寮?lt;鎰?lt;绛?lt;婊?lt;鐥?lt;钃?lt;瑁?lt; 璺?lt;杈?lt;寮?lt;纰?lt;绠?lt;钄?lt;澹?lt;瀣?lt;绡?lt;钖?lt;閬?lt;婵?lt;鑷?lt;楂< 鐠?lt;瑗?lt;杈?lt;鐮?lt;绗?lt;?#32042;<?#21504;<铦?lt;槌?lt;闉?lt;璐?lt;鎵?lt;绐?lt;鍖?lt; 纰?lt;瑜?lt;鍗?lt;寮?lt;蹇?lt;姹?lt;鑻?lt;鎷?lt;渚?lt;鍙?lt;?#32033;<閬?lt;杈?lt;杈?lt; 杈?lt;鐏?lt;鏉?lt;褰?lt;鏍?lt;椋?lt;楂?lt;楠?lt;鑶?lt;鐦?lt;闀?lt;椋?lt;椋?lt;闀?lt; 琛?lt;濠?lt;瑁?lt;槌?lt;鎲?lt;槌?lt;鍒?lt;韫?lt;鐦?lt;瀹?lt;褰?lt;鍌?lt;鏂?lt;婊?lt; 缂?lt;妲?lt;闀?lt;婵?lt;璞?lt;鎽?lt;娈?lt;鑶?lt;楂?lt;楝?lt;鍐?lt;鍐?lt;鍏?lt;涓?lt; 閭?lt;绉?lt;鏌?lt;鐐?lt;楗?lt;绂<骞?lt;鐥?lt;鎽?lt;鎷?lt;娉?lt;鐜?lt;鍓?lt;閽?lt; 楗?lt;鍟?lt;鑴?lt;鑿?lt;鎾?lt;浼?lt;瀛?lt;椹?lt;甯?lt;娉?lt;鍕?lt;浜?lt;閽?lt;閾?lt; ?#22487;<鍗?lt;?#34993;<楣?lt;鎼?lt;绠?lt;鑶?lt;韪?lt;钖?lt;绀?lt;璺?lt;绨?lt;鎿?lt;妾?lt; 閫?lt;閽?lt;鏅?lt;閱?lt;鍗?lt;鍗?lt;琛?lt;鍝?lt;鎹?lt;涓?lt;甯?lt;姝?lt;鎬?lt;閽?lt; 閮?lt;鍩?lt;鐡?lt;绨?</span>  ;</li> </ol> </div> <div><span style="color: #ff33ff;"> <ol> <li>} </li> <li><strong><span style="color: #0000ff;">package</span> </strong>  sorting; </li> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.util.*; </li> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.text.*; </li> <li><em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;"> * @author GaoJianMin</span> </em> </li> <li><em><span style="color: #339900;"> *</span> </em> </li> <li><em><span style="color: #339900;"> */</span> </em> </li> <li><strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">class</span> </strong>  ChineseGB2312Comparator <strong><span style="color: #0000ff;">implements</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/util/Comparator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Comparator</span> </span> </a> </strong> <<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong> >, <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/Comparable.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Comparable</span> </span> </a> </strong> <<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong> > { </li> <li>    <strong><span style="color: #0000ff;">private</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/text/RuleBasedCollator.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">RuleBasedCollator</span> </span> </a> </strong>  GB2312Collator = </li> <li>        ChineseGB2312Collator.getFixedGB2312Collator(); </li> <li>    <strong><span style="color: #0000ff;">private</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  str1; </li> <li>     </li> <li>    <em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;">     * @param str1</span> </em> </li> <li><em><span style="color: #339900;">     */</span> </em> </li> <li>    <strong><span style="color: #0000ff;">public</span> </strong>  ChineseGB2312Comparator(<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  str1) { </li> <li>        <strong><span style="color: #0000ff;">this</span> </strong> .str1 = str1; </li> <li>    } </li> <li>    <em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;">     * </span> </em> </li> <li><em><span style="color: #339900;">     */</span> </em> </li> <li>    <strong><span style="color: #0000ff;">public</span> </strong>  ChineseGB2312Comparator() { </li> <li>        <strong><span style="color: #0000ff;">this</span> </strong> .str1=<span style="color: #ff33ff;">""</span> ; </li> <li>    } </li> <li>    <em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;">     * @param str1</span> </em> </li> <li><em><span style="color: #339900;">     * @param str2</span> </em> </li> <li><em><span style="color: #339900;">     * @return an integer indicatint the comparison result</span> </em> </li> <li><em><span style="color: #339900;">     * @see java.util.Comparator#compare(Object, Object)</span> </em> </li> <li><em><span style="color: #339900;">     */</span> </em> </li> <li>    <strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">int</span> </strong>  compare(<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  str1, <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  str2) { </li> <li>        <strong><span style="color: #0000ff;">return</span> </strong>  GB2312Collator.compare(str1, str2); </li> <li>    } </li> <li>    <em><span style="color: #339900;">/**</span> </em> </li> <li><em><span style="color: #339900;">     * @param str2</span> </em> </li> <li><em><span style="color: #339900;">     * @return an integer indicatint the comparison result</span> </em> </li> <li><em><span style="color: #339900;">     *  @see java.lang.Comparable#compareTo(Object)</span> </em> </li> <li><em><span style="color: #339900;">     */</span> </em> </li> <li>    <strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">int</span> </strong>  compareTo(<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  str2) { </li> <li>        <strong><span style="color: #0000ff;">return</span> </strong>  GB2312Collator.compare(str1, str2); </li> <li>    } </li> <li>} </li> <li><br /> <br /> </li> </ol> <h3>娴嬭瘯浠爜鍙?#32513;?#37835;?/h3> <br /> 浠爜锛?br /> <div class="codeStyle"> <ol> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.util.*; </li> <li><strong><span style="color: #0000ff;">import</span> </strong>  java.text.*; </li> <li><strong><span style="color: #0000ff;">public</span> </strong>  <strong><span style="color: #0000ff;">class</span> </strong>  Test </li> <li>{ </li> <li>        <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  [] test = <strong><span style="color: #0000ff;">new</span> </strong>  <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong> [] { </li> <li>                <span style="color: #ff33ff;">"浣?#28051;?</span> , </li> <li>                <span style="color: #ff33ff;">"娴嬭瘯"</span> , </li> <li>                <span style="color: #ff33ff;">"test"</span> , </li> <li>                <span style="color: #ff33ff;">"鎴?#28000;?</span> , </li> <li>                <span style="color: #ff33ff;">"銆傜"</span> , </li> <li>                <span style="color: #ff33ff;">"闀傜"</span> , </li> <li>                <span style="color: #ff33ff;">"["</span> , </li> <li>                <span style="color: #ff33ff;">"娴?</span> , </li> <li>                <span style="color: #ff33ff;">"鐨?</span> </li> <li>        }; </li> <li>      java.util.<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/util/Arrays.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">Arrays</span> </span> </a> </strong> .sort(test, <strong><span style="color: #0000ff;">new</span> </strong>  ChineseGB2312Comparator()); </li> <li>      <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/System.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">System</span> </span> </a> </strong> .out.println(<span style="color: #ff33ff;">"============"</span> ); </li> <li>      <strong><span style="color: #0000ff;">for</span> </strong> (<strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/String.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">String</span> </span> </a> </strong>  key : test) </li> <li>          <strong><a href="http://vtyi.javaeye.com/source/jdk142/java/lang/System.java.html" target="_blank"><span class="classLink"><span style="text-decoration: underline;">System</span> </span> </a> </strong> .out.println(key); </li> <li>} </li> </ol> </div> <br /> <br /> ChineseGB2312Comparator ?#34987;鍚屾椂瀹?#37916;?#27996;?nbsp;Comparator, Comparable 鎺?#37721;?#38171;?#26473;?#37837;蜂互鍚?#38003;?#28598;?#28003;?#37922;?nbsp;compare, compareTo 鏂规硶?#27537;鏃跺欓兘?#24434;?#20114;浣?#37922;?#26473;?#28051;被銆?/span></div> <img src ="http://www.67529968.com/caizh2009/aggbug/340974.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/caizh2009/" target="_blank">灏忚彍姣?#23011;?/a> 2010-12-17 13:22 <a href="http://www.67529968.com/caizh2009/archive/2010/12/17/340974.html#Feedback" target="_blank" style="text-decoration:none;">鍙?#29723;?#29831;勮</a></div>]]></description></item><item><title> Struts1?#25328;Struts2?#27537;?#23599;鍒拰瀵?#23011;?http://www.67529968.com/caizh2009/archive/2010/12/14/340702.html灏忚彍姣?#23011;?/dc:creator>灏忚彍姣?#23011;?/author>Tue, 14 Dec 2010 13:55:00 GMThttp://www.67529968.com/caizh2009/archive/2010/12/14/340702.htmlhttp://www.67529968.com/caizh2009/comments/340702.htmlhttp://www.67529968.com/caizh2009/archive/2010/12/14/340702.html#Feedback0http://www.67529968.com/caizh2009/comments/commentRss/340702.htmlhttp://www.67529968.com/caizh2009/services/trackbacks/340702.htmlAction ?#34987;: 
• Struts1瑕佹眰Action?#34987;缁?#37813;?#28051;涓?#37814;借薄?#29056;?#34987;銆係truts1?#27537;涓涓?#37829;?#38316;嶉棶棰樻槸浣?#37922;?#37814;借薄?#34987;?#32042;绋嬭?#28051;嶆槸鎺?#37721;?#37510;?/span> 
• Struts 2 Action绫诲彲?#20114;瀹?#37916;?#28051;涓狝ction鎺?#37721;?#38171;?#28052;熷彲瀹?#37916;?#37711;?#28000;栨帴鍙?#38171;?#28003;垮彲閫夊拰瀹?#37714;剁殑鏈嶅?#22426;涓哄彲鑳?#37510;係truts2?#24385;渚?#28051;涓狝ctionSupport?#29056;绫诲幓 瀹?#37916;??#29238;鐢殑鎺?#37721;?#37510;侫ction鎺?#37721;?#28051;嶆槸蹇?#26916;荤殑锛?#28000;?#28003;?#37832;塭xecute鏍?#29831;嗙殑POJO瀵硅薄閮藉彲?#20114;鐢?#28003;淪truts2?#27537;Action瀵硅薄銆?/span> 

绾跨?#23339;寮? 
• Struts1 Action?#27128;鍗曚緥妯?#23534;?#39582;?#28051;?#36423;?#26916;绘槸绾跨瀹夊叏?#27537;锛屽洜涓?#28000;?#37832;堿ction?#27537;涓涓?#28729;炰緥鏉?#28598;?#37918;?#37813;鏈夌殑璇锋眰銆傚?#26330;緥绛?#37923;?#38340;?#37714;?#27996;Struts1 Action鑳?#28003;滅殑浜?#38171;?#39582;?#28051;?#29781;?#37734;?#23534;鍙戞椂鐗?#37714;?#28751;?#36423;?#37510;侫ction璧勬簮蹇?#26916;绘槸绾跨瀹夊叏?#27537;鎴?#37722;屾?#27537;銆?/span> 
• Struts2 Action瀵硅薄涓?#23011;?#28051;涓?#29831;锋眰浜?#37922;?#28051;涓?#28729;炰緥锛屽?#29363;?#30149;鏈夌?#36328;瀹夊叏?#26870;棰樸?#38171;?#28729;?#38340;?#28051;?#38171;宻ervlet瀹瑰櫒缁?#23011;?#28051;?#29831;锋眰浜?#37922;?#29825;?#28598;氬彲涓?#23534;冪殑瀵硅薄锛?#39582;?#28051;?#28051;嶄細瀵?#38007;?#37804;?#38003;藉拰鍨?#37734;?#37733;炴?#22549;棶棰?#38171;?/span> 

Servlet ?#32247;璧? 
• Struts1 Action ?#32247;璧?#27996;嶴ervlet API ,鍥?#28051;哄綋涓涓狝ction琚皟鐢椂HttpServletRequest ?#25328; HttpServletResponse 琚?#28028;?#38315;?#32513;execute鏂规硶銆?/span> 
• Struts 2 Action涓嶄緷璧?#27996;庡?#29808;櫒锛屽厑璁窤ction鑴辩瀹瑰櫒鍗曠嫭琚?#23092;嬭瘯銆?#28641;?#37835;滈渶瑕?#38171;孲truts2 Action浠嶇?#36346;彲?#20114;璁块棶鍒?#28654;嬬殑request?#25328;response銆?#28003;嗘槸锛屽叾浠栫殑?#21395;绱?#37713;?#28751;?#37812;?#38000;呮?#22565;櫎浜?#37929;存帴璁块棶HttpServetRequest ?#25328; HttpServletResponse?#27537;蹇呰鎬?#37510;?/span> 

?#24434;?#31092;鎬? 
• 娴嬭瘯Struts1 Action?#27537;涓涓?#28051;?#29781;侀棶棰樻槸execute鏂规硶鏆?#38343;?#27996;唖ervlet API锛?#26473;?#28003;?#23536;楁?#23341;瘯瑕佷緷璧?#27996;庡?#29808;櫒锛?#37510;?#28051;涓?#32471;?#28051;?#37826;?#37813;?#28766;?#38171;?#38171;Struts TestCase锛?#38171;嶆彁渚?#27996;?#28051;濂桽truts1?#27537;妯?#37815;?#28725;硅薄锛?#37833;?#26473;?#29723;屾?#23341;瘯锛?#37510;?/span> 
• Struts 2 Action?#24434;?#20114;閫氳繃鍒?#28654;嬪寲銆?#29825;剧疆?#30552;鎬?#37510;佽皟鐢?#37826;规硶鏉?#23092;嬭瘯锛?#8220;?#32247;璧?#23049;?#37711;?#8221;?#25966;鎸?#28052;?#28003;?#23092;嬭瘯鏇?#28729;规銆?/span> 

鎹?#38014;疯緭鍏? 
• Struts1 浣?#37922;ActionForm瀵硅薄鎹?#38014;疯緭鍏?#37510;?#37813;鏈夌殑ActionForm蹇?#26916;?#32513;?#37813;?#28051;涓熀?#34987;銆?#37733;?#28051;?#37711;?#28000;朖avaBean涓嶈兘鐢?#28003;ActionForm锛?#23534;鍙戣?#32513;??#29238;鍒涘缓澶氫?#27409;殑?#34987;鎹?#38014;疯緭鍏?#37510;?#37716;?#37804;丅ean锛圖ynaBeans锛夊彲?#20114;浣?#28051;?#37714;涘缓浼?#32513;烝ctionForm?#27537;閫夋嫨锛?#28003;嗘槸锛?#23534;鍙戣呭彲鑳芥槸鍦?#38322;?#37826;版?#24538;堪(鍒涘缓)宸?#32513;?#28699;?鍦殑JavaBean锛?#28000;嶇?#26421;細瀵?#38007;?#37832;夊啑浣欑殑javabean锛?#37510;?/span> 
• Struts 2鐩存帴浣?#37922;Action?#30552;鎬?#28003;?#28051;鸿緭鍏睘鎬?#38171;屾?#22565;櫎浜嗗绗?#27996;?#28051;緭鍏?#28725;硅薄?#27537;?#28214;?#30512;銆傝緭鍏睘鎬彲鑳芥槸鏈夎嚜宸?瀛??#30552;鎬殑rich瀵硅薄绫诲瀷銆侫ction?#30552;鎬?#38003;?#28598;?#38315;氳繃 web椤?#38344;?#28051;婄殑taglibs璁块棶銆係truts2涔熸敮鎸丄ctionForm妯?#23534;?#37510;俽ich瀵硅薄绫诲瀷锛?#37718;呮嫭涓氬瀵硅薄锛?#38003;?#28598;?#37922;?#28003;滆緭鍏??#32237;鍑?#28725;硅薄銆?#26473;?#32457;?ModelDriven 鐗?#37804;?#32480;鍖?#27996;taglib瀵筆OJO?#32237;鍏?#28725;硅薄?#27537;寮?#37922;?#37510;?/span> 

琛?#26440;?#23534;忚瑷锛?/span> 
• Struts1 ?#26275;鍚?#27996;咼STL锛屽?#29363;浣?#37922;JSTL EL銆?#26473;?#32457;岴L鏈夊熀鏈?#28725;硅薄鍥?#38316;嶅巻锛?#28003;嗘槸瀵归泦鍚堝拰绱?#23534;曞睘鎬殑?#25966;鎸?#23536;?#23534;?#37510;?/span> 
• Struts2?#24434;?#20114;浣?#37922;JSTL锛?#28003;嗘槸涔熸敮鎸?#28051;涓?#37831;?#23534;?#28598;拰鐏垫椿?#27537;琛?#26440;?#23534;忚瑷锛?#38171;?Object Graph Notation Language" (OGNL). 

缁?#28729;?#37706;煎埌椤?#38344;?#38171;坴iew锛? 
• Struts 1浣?#37922;?#37837;?#37713;咼SP鏈?#37714;?#37814;婂?#30789;薄缁?#28729;氬埌椤?#38344;?#28051;?#37833;?#29825;块棶銆?/span> 
• Struts 2 浣?#37922;?"ValueStack"鎶鏈?#38171;?#28003;縯aglib鑳?#28598;?#29825;块棶鍊?#38000;?#28051;嶉渶瑕?#37814;?#28003;犵殑椤?#38344;?#38171;坴iew锛夊拰瀵硅薄缁?#28729;氳捣鏉?#37510;俈alueStack绛?#37923;?#37711;?#29825;?#38315;氳繃涓绯?#37714;?#37722;嶇?#25198;浉鍚?#28003;?#32491;诲瀷涓?#37722;岀殑?#30552;鎬?#38322;?#37922;?#26916;?#38344;?#38171;坴iew锛?#37510;?/span> 

绫诲?#23341;浆鎹?#38171;?/span> 
• Struts 1 ActionForm ?#30552;鎬?#38315;氬父閮芥槸String绫诲瀷銆係truts1浣?#37922;Commons-Beanutils杩?#29723;岀?#35826;?#23341;浆鎹?#37510;?#23011;?#28051;被涓涓浆鎹櫒锛屽姣?#28051;涓?#28729;炰緥鏉?#29831;存槸涓嶅彲閰嶇疆?#27537;銆?/span> 
• Struts2 浣?#37922;OGNL杩?#29723;岀?#35826;?#23341;浆鎹?#37510;傛彁渚涘熀鏈拰?#29238;鐢?#28725;硅薄?#27537;?#27974;鎹櫒銆?/span> 

鏍?#26976;?#38171;?/span> 
• Struts 1?#25966;鎸?#37734;ActionForm?#27537;validate鏂规硶涓?#37813;嬪姩鏍?#26976;?#38171;屾垨鑰?#38315;氳繃Commons Validator?#27537;鎵?#28766;?#37833;?#37837;?#26976;屻?#37722;?#28051;涓?#32491;诲彲?#20114;鏈?#28051;?#37722;岀殑鏍?#26976;?#37712;?#28729;?#38171;?#28003;?#28051;嶈兘鏍?#26976;?#28699;?#28725;硅薄銆?/span> 
• Struts2?#25966;鎸?#38315;氳繃validate鏂规硶?#25328;XWork鏍?#26976;屾鏋?#37833;?#26473;?#29723;屾牎楠屻俋Work鏍?#26976;屾鏋?#28003;?#37922;?#28051;哄睘鎬被绫诲瀷瀹氫?#22796;殑鏍?#26976;屽拰鍐?#28729;?#37837;?#26976;?#38171;屾潵?#25966;鎸chain鏍?#26976;?#28699;愬睘鎬?/span> 

Action鎵?#29723;岀殑鎺?#37714;?#38171;?/span> 
• Struts1?#25966;鎸?#23011;?#28051;涓?#22959;?#37735;?#37832;夊?#26336;嫭?#27537;Request Processors锛?#37922;熷鍛?#37832;?#38171;?#38171;?#28003;嗘槸妯?#37735;?#28051;殑鎵鏈堿ction蹇?#26916;诲叡浜?#37929;?#37722;岀殑鐢熷鍛?#37832;?#37510;?/span> 
• Struts2?#25966;鎸?#38315;氳繃鎷?#37812;櫒鍫?#37837;?#38171;圛nterceptor Stacks锛?#28051;?#23011;?#28051;涓狝ction鍒涘缓涓?#37722;岀殑鐢熷鍛?#37832;?#37510;傚爢鏍?#38003;?#28598;?#37837;规嵁?#28214;瑕佸拰涓?#37722;岀殑Action涓璧?#28003;?#37922;?#37510;?/span>

]]>
Android涓?#23075;诲姞Admob骞?#37723;?#38171;堣浆http://www.67529968.com/caizh2009/archive/2010/12/10/340283.html灏忚彍姣?#23011;?/dc:creator>灏忚彍姣?#23011;?/author>Fri, 10 Dec 2010 09:42:00 GMThttp://www.67529968.com/caizh2009/archive/2010/12/10/340283.htmlhttp://www.67529968.com/caizh2009/comments/340283.htmlhttp://www.67529968.com/caizh2009/archive/2010/12/10/340283.html#Feedback2http://www.67529968.com/caizh2009/comments/commentRss/340283.htmlhttp://www.67529968.com/caizh2009/services/trackbacks/340283.html鑺?#27996;嗘暣?#26275;涓澶椂闂?#38171;岀?#26050;鎬?#28052;?#38315;氳繃鍦?font style="background-color: #00ffff;">Android
搴?#37922;?#32459;嬪簭涓?#23075;诲姞Admob骞?#37723;?#37833;?#29863;氶挶銆傜綉涓?#28052;?#37832;?#27996;涙?#27409;锛?#28051;?#26473;?#29831;?#23536;?#28051;嶅璇?#32513;?#38171;岃嚜宸?#26473;?#23536;?#38010;辨椂闂存懜绱?#37510;?#28051;?#27996;?#29825;?#37722;?#37833;?#38000;呰?#33445;洿蹇?#23534;濮婣dmob骞?#37723;?#29863;氶挶锛屾墍?#20114;?#21843;涓?#29831;?#32513;?#28051;?#20579;?#27537;鏁欑锛屼緵澶?#28729;跺弬鑰?#37510;?/p>

?#32229;瀛?#23480;?#32459;嬫簮?#29212;涓嬭浇鍦板潃锛?寤?#29825;?#28003;?#37922;?#23092;忚?#22557;櫒?#22172;甯殑涓嬭浇宸?#37711;?#28051;嬭浇)http://cid-cb78b387364ae9a7.skydrive.live.com/browse.aspx/.Public/%e8%bd%af%e4%bb%b6/Andoroid
?#32139;?#21159;锛屾垜涔?#37721;?#38000;?#27996;?#28051;浜涚綉涓婄殑璧?#37826;?#38171;?#28051;?#29781;?#37832;?#38171;?/p>

AdMob锛?#37734;?font style="background-color: #00ffff;">android搴?#37922;?#28051;?#23443;屽叆骞?#37723;婄殑鏂规
濡?#28003;?#37734;?font style="background-color: #00ffff;">Android
Market璧氶挶 part 2 - 鍏嶈垂app闄勫甫骞?#37723;?br /> Publisher Starter Kit
闈?#37722;?#23534;鍙戣?Wiki ?#27537; AdMob

濂?#27996;?#38171;岀幇鍦?#29825;?#37812;?#28000;庡寮濮嬭璧?#8230;…鍦?#26473;欎?#23338;墠锛?#28003;?#28051;嶉渶瑕?#37832;?#28000;?#28003;曠殑甯?#37721;?#38171;屽敮涓?#28214;瑕佺殑灏辨槸鏈?#28051;涓?#37832;夋?#22562;殑email閭?#32480;?#37510;?#37721;?#29781;?#37816;夌収涓?#38344;殑姝?#26976;?#28051;姝?#23005;?#37833;?#38171;?#28003;?#28751;?#38003;?#38315;氳繃灏咥dmob?#27537;骞?#37723;?#37819;掑埌?#22172;宸辩殑绋嬪簭涓?#29863;氶?#21342;暒锛?/p>

棣?#37711;?#38171;屽綋鐒舵槸?#28214;瑕?#23049;?#37712;?#28051;涓狝dmob?#27537;甯?#37721;?#37510;侫dmob?#27537;涓?#26916;垫槸锛?a href="http://www.admob.com/">http://www.admob.com/ 銆??#32139;?#21159;锛屽鏋?#28003;犲浜?#23092;忚?#22563;鏂囩綉椤?#26473;?#37832;?#27996;涢?#28357;?#23943;殑璇?#38171;屽彲?#20114;鐧?#35120;?#28051;?#37826;囩綉绔?#38171;?a href="http://zhcn.admob.com/">http://zhcn.admob.com/ 銆?#28641;?#37835;滅綉绔欑殑鏂?#28699;?#26473;樻槸鑻?#37826;?#38171;?#28003;犲彲?#20114;鍦?#32515;?#32468;?#28051;?#26916;电殑鍙?#28051;?#29785;掔殑“Language”澶?#38171;?#38315;夋嫨“涓?#37826;?#38171;?#32480;?#32139;锛?#8221;銆傜偣鍑?#26473;?#37711;?#23049;?#37712;岄闈?#37722;?#38171;?#37832;?#28051;浜涙?#24533;洰?#28214;瑕佸?#21843;锛?#28051;嶈澶? 杩囩?#25123;锛?#28751;卞儚浣犳敞鍐?#28051;涓?#29825;哄涓鏍?#38171;岄?#24526;?#22446;涓?#28751;卞浜?#37510;?#37832;鍏?#38335;殑?#27128;淇?#29831;佸?#21843;?#27537;email鍦板潃鏈夋晥锛屽彟澶?#28751;辨槸濉?#28051;?#28654;?#37722;?#38171;?#38315;夋嫨璇?#29815;銆傚?#24877;埛绫诲?#23339;垜閫夋嫨?#27537;“涓嶇瀹?#8221;锛? 璇?#29815;“涓?#37826;?#38171;?#32480;?#32139;锛?#8221;锝??#24385;浜?#23049;?#37712;?#37922;?#29831;?#28052;?#37722;?#38171;?#28051;?#28052;?#28003;?#28751;变細鏀跺埌鐢?#27996;?#32429;?#29825;?#39582;舵縺娲诲笎鍙风殑鐢?#28699;?#38317;欢锛岀偣鍑绘縺?#26943;閾炬帴锛?#28751;卞彲?#20114;浜嗘縺?#26943;浣犵殑Admob甯?#37721;?#27996;嗭綖

绗?#27996;屾灏辨槸璁剧疆浣犵殑Android搴? 鐢?#32459;嬪?#24526;俊?#20229;锛?#39582;?#38014;?#23536;桝dmob?#27537;鎻?#37711;?#28000;爜銆傜櫥褰?#28003;犵殑Admob甯?#37721;?#37722;?#38171;?#37734;?#28051;?#26916;电殑宸?#28051;?#37826;?#38171;Logo涓?#38344;?#38171;夌偣鍑?#8220;Marketplace锛?#37813;?#37832;?#39582;?#37723;婂競鍦?#38171;?#8221;锛? 杩?#37711;?#26916;?#38344;?#37722;?#38171;?#37734;?#8220;Sites&Apps锛?#32468;欑偣?#25328;搴?#37922;?#32459;嬪簭锛?#8221;鏍囩涓?#38171;岀偣鍑?#8220;Add Site/App”銆?#38315;夋嫨鎴?#28000;?#37908;熸?#22796;殑鍥?#37837;?#37413;?#37413;? Android App ” 銆?#26473;欐椂?#32048;鍑?#37916;伴渶瑕?#28003;犲?#21843;涓涓?#8220;璇?#32513;嗕俊?#20229;”锛岄?#24526;?#22446;涓?#28051;浜?#28103;伅銆?#38171;?#28051;嶈澶?#26473;?#37734;剰鐜?#37734;?#28617;啓?#27537;涓滆锛屽洜涓?#26473;?#27996;涗互鍚?#38318;芥槸?#24434;?#20114;淇敼?#27537;锛?#37510;?#23011;?#28641;?#8220;Android Package URL” 鎴戝埌鐜?#37734;?#38318;?#26473;樻病鏈夊?#21843;锛屾?#24538;堪涔嬬被?#27537;锛屾兂?#21843;灏卞啓?#20579;鍚?#37510;傚濂?#29831;?#32513;嗕俊?#20229;鍚?#38171;岀偣鍑?#8220;缁?#32513;?#8221;锛?#28751;卞彲?#20114;?#22476;AdMob Android SDK ?#27537;涓嬭浇椤?#38344;?#27996;?#37510;?#28051;嬭浇杩?#28051;猄DK锛堝綋?#21159;锛?#26473;?#28051;?#23536;?#38322;嶈锛?#37510;?/p>

The AdMob Android SDK includes:

README: Get started with AdMob Android ads!
AdMob Jar file: Required for publishing ads. Follow the documentation in javadoc/index.html and drop the AdMob Jar file into your project.
Sample Projects: Examples of AdMob Android ads shown in the LunarLander application.

绗?#28051;?#23005;?#38014;峰彇浣犵殑搴?#37922;?#32459;嬪簭瀵?#25652;旂殑Publisher ID銆?#37734;?#28051;嬭浇椤?#38344;偣鍑?Go to Sites/Apps"灏卞彲?#20114;?#22476;浣犲簲鐢?#32459;嬪?#24533;殑绠?#37918;?#37923;?#38344;?#27996;?#37510;?#26473;欐椂浣犱細鍙?#37916;?#37734;?#26473;?#28051;?#26916;?#38344;?#38321;掔洰?#27537;浣嶇疆?#32048;鏈?#28051;涓?#37721;?#28003;犲?#21843;璇?#32513;嗕俊?#20229;?#27537;?#24385;绀?#38171;?/p>

鍦?#37812;?#28000;?#37721;?#38315;?#28000;?#28003;?#37832;夊?#21614;?#36346;叆涔嬪墠锛屾?#28214;瑕佸?#21843;鎶鏈?#38001;?#32495;?#29831;?#32513;嗕俊?#20229;?#25328;浠樻棣?#38315;夐銆?/p>

鎴?#28000;?#37830;?#37827;跺彲?#20114;涓?#37922;?#32480;?#28729;?#38171;屽洜涓洪?#36776;槸?#32048;瀛?#37734;?#37812;?#28000;殑Admob?#27537;璐埛涓婄殑锛?#32475;?#37812;?#28000;渶瑕佹彁鐜扮殑鏃跺?#38171;屾垨鑰?#28003;犳兂濉殑鏃跺?#37712;嶅灏卞彲?#20114;浜?#37510;?#37734;?#28051;?#38344;殑鍒?#29723;?#28051;?#38171;?#38315;夋嫨浣? ?#27537;搴?#37922;?#32459;嬪簭骞?#26473;?#37711;?#37510;?#26473;?#28051;?#37923;?#38344;?#28751;辨槸浣犵殑搴?#37922;?#32459;嬪簭骞?#37723;婄殑绠?#37918;?#37923;?#38344;?#27996;?#38171;?#38322;?#38344;?#37832;?#23011;?#26440;?#28598;氱殑鍔?#38003;?#38171;屼互鍚庡彲?#20114;鎱?#37809;?#27996;?#29785;?#38171;岀幇鍦?#37812;?#28000;?#37721;渶瑕?#37933;亾涓?#28051;?#28051;滆锛?#28051;涓槸鍙戝竷鑰? ID锛圥ublisher ID锛?#38171;?#28051;涓槸浣?#32459;嬪?#24533;殑?#23032;鎬?#37510;侾ublisher ID?#27128;涓涓?5涓?#28699;?#32471;殑瀛?#32471;?#28051;?#38171;?#38000;?#28003;?#32459;嬪?#24533;殑?#23032;鎬?#37916;?#37734;?#25652;?#29831;?#26473;樻槸涓嶆?#35826;姩锛圛nactive锛?#37510;傛垜浠?#28051;?#38344;?#29781;?#37707;氱殑灏辨槸鎬?#28052;?#29825;?#28729;?#37721;?#28051;篈ctive銆?/p>

绗?#37733;涙浠爜?#32042;?#21843;鈥?#37413;?#37734;?#28003;犵殑搴?#37922;?#32459;嬪簭涓?#37819;?#37711;Admob骞?#37723;?#37510;?#32513;忚繃涓?#38344;殑姝?#26976;?#38171;屾垜浠?#37734;?#32515;?#32468;?#28051;婄殑璁剧疆灏卞憡涓涓?#23048;佃浜?#38171;岀幇鍦?#37812;?#28000;?#32513;?#27996;?#29781;?#26473;?#37711;?#28051;?#26864;?#27996;?#38171;屽浣?#37734;嚜宸辩殑Android搴?#37922;?#32459;嬪簭涓?#37819;?#37711;Admob骞?#37723;?#37510;?#28641;?#37835;?#28003;?#28051;嶅仴蹇樼殑璇?#38171;?#28051;瀹氳繕璁?#23536;楁垜浠?#28052;嬪墠涓嬭?#30028;殑閭?#28051;狝dMob Android SDK 銆?#29785;?#37720;?#28729;?#38171;岀湅鐪?#38322;?#38344;?#37832;?#27996;?#28000;涔?#28051;滆銆?#26473;?#38322;?#38344;?#37832;閲嶈?#20346;殑灏辨槸閭?#28051;?#37722;?#28051;?#8220;admob-sdk-android.jar”?#27537;鍖呭暒锛孉dmob灏嗗浣?#37814;?#39582;?#37723;婂姞杞藉埌Android搴?#37922;?#32459;嬪簭涓殑浠爜闆嗘垚鍦?#26473;?#28051;?#37718;?#38322;?#38171;屾垜浠紪?#21843;绋嬪?#24533;殑鏃跺?#28751;遍渶瑕?#28751;?#26473;?#28051;?#37718;呭?#29006;叆?#22476;鎴?#28000;殑宸?#32459;?#38322;?#38344;?#37720;?#37510;?#37721;?#28598;?#38171;?#29785;?#37720;?#37713;?#37833;殑鏂囦?#36346;涓?#26473;?#37832;?#28051;涓?#37722;?#28051;?#8220;javadoc”?#27537;鏂囦?#36346;锛屾墦寮瀹?#38322;?#38344;殑index.html銆?#28729;冩槸鍏?#27996;嶢dmob Android SDK?#27537;甯?#37716;?#37826;?#22935;?#38171;?#37734;Package 涓嬬殑Setup涓?#38171;?#37832;?#29831;?#32513;?#28729;屾暣?#27537;鍦嚜宸辩殑搴?#37922;?#32459;嬪簭涓?#37819;?#37711;?#39582;?#37723;婄殑鏂规硶浠?#32513;?#38171;?#37734;?#26473;?#38322;屾垜灏卞?#38155;噿锛?#23534;?#37922;?#28051;涓嬶綖


Including the Jar
Add the Jar file included with the SDK to your Android project as an external library. In your project's root directory create a subdirectory libs (this will already be done for you if you used Android's activitycreator). Copy the AdMob Jar file into that directory. For Eclipse projects:

Go to the Properties of your project (right-click on your project from the Package Explorer tab and select Properties)
Select "Java Build Path" from left panel
Select "Libraries" tab from the main window
Click on "Add JARs..."
Select the JAR copied to the libs directory
Click "OK" to add the SDK to your android project

娉剰锛氶渶瑕侀鍏?#37734;?#28003;?#23480;?#32459;嬬殑鏍圭洰褰?#28051;?#37826;板缓涓涓?#37721;?#37707;?#8220;libs”?#27537;鏂囦?#36346;锛?#39582;?#37814;?#28052;嬪墠鎵璇寸殑鏈閲嶈?#20346;殑涓滆“admob-sdk-android.jar”澶嶅?#36346;埌閲?#38344;?#37510;?/p>


AndroidManifest.xml

Your AdMob publisher ID was given to you when creating your publisher account on www.admob.com before downloading this code. It is a 15-character code like a1496ced2842262. Just before the closing </application> tag add a line to set your publisher ID:


                <!-- The application's publisher ID assigned by AdMob -->
                <meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID" />
        </application>
Set any permissions not already included just before the closing </manifest> tag:
                <!-- AdMob SDK permissions -->
                <uses-permission android:name="android.permission.INTERNET" />
                <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        </manifest>

Only the INTERNET permission is required. Setting ACCESS_COARSE_LOCATION (and/or ACCESS_FINE_LOCATION) allows narrowly geo-targeted ads be shown.

杩?#38322;岄渶瑕?#23049;剰?#27537;?#27128;锛?lt;meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID" />涓?#38171;屾垜浠?#37721;渶瑕佹敼?#27537;?#27128;"YOUR_ID_HERE"銆?#26473;?#38322;岄渶瑕?#28003;犲涓婄殑ID灏辨槸鎴?#28000;?#28052;嬪墠鍦Admob缃?#32468;欐垜浠殑搴?#37922;?#32459;嬪簭绠?#37918;嗛闈?#28051;?#37930;嬪埌?#27537; Publisher ID锛?#38000;宯ame="ADMOB_PUBLISHER_ID"?#27128;涓嶅簲璇敼?#27537;銆傜?#23338;?#24539;渶瑕?#26473;?#28051;狵ey鏉?#37836;?#37813;?#28725;?#25652;旂殑Value銆?/p>

attrs.xml
The attrs.xml file specifies custom AdView attributes in XML layout files. If your application does not already have an /res/values/attrs.xml file then create one and copy-and-paste the following into it. If you do have that file then just add the declare-styleable element:


        <?xml version="1.0" encoding="utf-8"?>
        <resources>
                <declare-styleable name="com.admob.android.ads.AdView">
                        <attr name="testing" format="boolean" />
                        <attr name="backgroundColor" format="color" />
                        <attr name="textColor" format="color" />
                        <attr name="keywords" format="string" />
                        <attr name="refreshInterval" format="integer" />
                        <attr name="isGoneWithoutAd" format="boolean" />
                </declare-styleable>
        </resources>

杩?#28051;?#38171;屾病浠涔?#29831;寸殑銆?/p>


Placing an AdView in a Layout
AdView widgets can be put into any XML layout now. The first step is to reference attrs.xml in your layout element by adding an xmlns line that includes your package name specified in AndroidManifest.xml:


        xmlns:yourapp=http://schemas.android.com/apk/res/yourpackage

For example a simple screen with only an ad on it would look like:


        <?xml version="1.0" encoding="utf-8"?>
        <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:admobsdk="http://schemas.android.com/apk/res/com.admob.android.example"
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
   
                <com.admob.android.ads.AdView
                        android:id="@+id/ad"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        admobsdk:backgroundColor="#000000"
                        admobsdk:textColor="#FFFFFF"
                        admobsdk:keywords="Android application"
                />
                       
        </LinearLayout>

杩?#38322;屽鍍?#28052;熸病浠涔堥渶瑕?#37911;?#37714;?#23049;剰?#27537;锛屾敞?#21104;鍔?#28051;妜mlns锛屽彟澶栫煡?#20158;杩?#38322;屽彲?#20114;璁剧疆涓涓猭eywords

Test Mode
When you start integrating AdMob ads into your application it is recommended to use test mode. This always returns the same ad. Normal ad requests are not deterministic making it harder to be sure the ad view looks like you want (e.g. ad requests can timeout or may not fill).

Once the ad shows up as you expect be sure to turn test mode off to get real ads. Never put your application into the Android Market with test mode enabled.

Test mode can be enabled either by calling AdManager.setInTestMode(true) or by adding a "admobsdk:testing="true"" property to the ad in your XML layout (where "admobsdk" is the XML namespace for your application).


璁剧疆Test Mode杩?#28051;?#23536;?#37711;?#38335;?#38171;屽涓?#37714;?#28751;?#28598;?#27996;Test Mode?#27537;绋嬪簭鍙戝竷鍑?#37720;?#27996;?#38171;?#38317;?#37837;峰彲璧?#28051;?#27996;嗛?#21342;?#23119;綖锛?#28641;?#37835;?#37734;AdView?#27537;?#30552;鎬?#28051;?#28051;嶅姞涓奱dmobsdk:testing="false"锛?#28028;?#28052;?#32459;嬪簭涔熸槸涓嶅浜Test Mode?#27537;锛?#28051;?#26473;?#37832;濂?#26473;樻槸鍔?#28051;?#37722;?#38173;?/p>

绗?#27996;?#23005;紪璇?#26473;愯锛?#39582;舵縺?#26943;绋嬪簭銆傜紪璇?#26473;愯浣犵殑绋嬪簭锛?#37734;?#22959;?#37815;熷櫒涓?#28751;卞彲?#20114;鐪嬪埌鏁?#37835;滃暒锝?#38171;堝綋?#21159;浣犵殑妯?#37815;熷櫒?#28214;瑕佽兘涓?#32515;?#38171;屽叧浜?#37804;?#28052;?#29825;?#22959;?#37815;熷櫒涓?#32515;戝憿锛?#37922;矾鐢辩殑搴?#29831;? ?#24434;?#20114;鐩存帴涓?#38171;屽鏋?#28051;嶆槸鐢矾鐢?#38171;?#38317;?#28052;堝彲鑳介渶瑕?#29825;剧疆涓?#38171;屽?#34562;綋鏂规硶澶?#28729;惰嚜宸辩綉涓?#37820;?#37722;?#38171;屽?#34562;綋蹇?#27996;?#38171;?#37510;?#28641;?#37835;?#28003;犵殑搴?#37922;?#32459;嬪?#24538;兘鏄剧鍑?#39582;?#37723;?#38171;?#38317;?#28052;堟鍠?#28003;?#38171;?#28003;犵殑搴?#37922;?#32459;嬪簭寰?#36423;? 灏变細鍦Admob涓?#29722;?#23157;?#26943;浜?#38171;堥渶瑕?#28051;瀹氱殑?#26882;闂?#38171;屾垜?#27537;濂?#37709;忚姳浜?#28051;涓?#28751;忔椂涓嶅埌锛?#38171;?/p>

绗?#37711;?#23005;?#37734;Admob缃?#32468;?#28051;?#37836;?#37930;嬪簲鐢?#32459;嬪?#24538;禋浜?#28598;?#28751;戦挶锝?#8220;鎵?#37832;?#39582;?#37723;婂競鍦?#8221;鈥?gt;“鎶?#37723;?#8221;鈥?gt;“绔欑偣?#25328;搴?#37922;?#32459;嬪簭鎶?#37723;?#8221;銆?#38315;夋嫨浣犵殑搴?#37922;?#32459;嬪簭锛岀?#36346;悗?#20579;鍑?#26916;?#38344;?#37832;涓?#38344;殑“鍒涘缓鎶?#37723;?#8221;锝?OK锛?#29863;氶?#21342;暒锝?/p>

鏈鍚?#38171;屾垜鎶?#37812;戣嚜宸卞啓?#27537;涓涓緥瀛?#23480;?#32459;?#28051;?#28028;?#28051;?#37833;?#38171;?#28598;?#28729;跺彲?#20114;涓嬭浇鏉?#37721;?#38000;?#28051;?#37510;?#37721;?#28598;?#38171;屾垜?#27537;宸?#32459;?#28751;?#39582;?#37723;?#28003;?#28051;?#32457;诲姩?#27537;锛?#39582;?#28051;旀敼鍙?#27996;?#28729;?#27035;?#29825;殑瀹?#25652;拰鑳屾锛屽笇鏈?#28725;瑰浣?#37734;?#25652;?#37922;?#32459;嬪簭涓?#37821;嗘斁骞?#37723;?#38171;?#29863;峰埌涓涓?#37814;涚寮?#37916;夌殑浣?#37922;?#37510;傛晥鏋?#37733;惧涓?#38171;堝?#22557;搱锛?#37734;?#22959;?#37815;熷櫒璺戠殑锝?#38171;?#38171;?/p>



1.http://www.admob.com/娉?#37712;?#28051;涓?#29999;?#37721;?#38171;?/h3>

娣诲姞Add Mobile Site/app锛岃緭鍏?#37929;?#37711;?#28103;伅鍚?#38171;屾彁浜?#28729;屾垚锛?/p>

涓嬭浇Android骞?#37721;?#28003;?#37922;殑JAR锛屾煡鐪嬪?#25117;竷鑰?ID銆?/p>

2.鐒跺悗灏咼AR娣诲?#29362;埌浣犵殑椤圭洰涓?/h3>

Properties->Java Build Path->Libraries->Add JARs…->Select the JAR->OK

3.?#32042;杈慉ndroidManifest.xml

application鑺傜偣涓?#23075;诲姞

<!– The application’s publisher ID assigned by AdMob –>

<meta-data android:value=”a14ae1ce0357305″ android:name=”ADMOB_PUBLISHER_ID” />

manifest鑺傜偣娣诲?#29363;闄?#37922;?#29831;?/p>

<!– AdMob SDK permissions –>

<uses-permission android:name=”android.permission.INTERNET” />

4.娣诲姞attrs.xml

/res/values/attrs.xml

<?xml version=”1.0″ encoding=”utf-8″?>

<resources>

<declare-styleable name=”com.admob.android.ads.AdView”>

<attr name=”testing” format=”boolean” />

<attr name=”backgroundColor” format=”color” />

<attr name=”textColor” format=”color” />

<attr name=”keywords” format=”string” />

<attr name=”refreshInterval” format=”integer” />

<attr name=”isGoneWithoutAd” format=”boolean” />

</declare-styleable>

</resources>

5.娣诲姞骞?#37723;?#32513;勪欢

<?xml version=”1.0″ encoding=”utf-8″?>

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”

xmlns:admobsdk=”http://schemas.android.com/apk/res/com.moandroid.livesports”

android:orientation=”vertical”

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”

>

<TextView

android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

android:text=”@string/hello”

/>

<com.admob.android.ads.AdView

android:id=”@+id/ad”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

admobsdk:backgroundColor=”#000000″

admobsdk:textColor=”#FFFFFF”

admobsdk:keywords=”Android application”

admobsdk:refreshInterval=”60″

/>

</LinearLayout>

6.鏄剧鏁?#37835;?/h3>

涓?#37711;嶈垂app宓屽叆Admob骞?#37723;?#38171;?#26473;?#38000;?#38014;?#23536;?#39582;?#37723;?#37824;跺叆銆?/p>

adm



]]>?#23599;?#22414;Activity?#27537;鍥?#32457;嶅姞杞?#22959;?#23534;?/title><link>http://www.67529968.com/caizh2009/archive/2010/12/10/340227.html</link><dc:creator>灏忚彍姣?#23011;?/dc:creator><author>灏忚彍姣?#23011;?/author><pubDate>Fri, 10 Dec 2010 02:38:00 GMT</pubDate><guid>http://www.67529968.com/caizh2009/archive/2010/12/10/340227.html</guid><wfw:comment>http://www.67529968.com/caizh2009/comments/340227.html</wfw:comment><comments>http://www.67529968.com/caizh2009/archive/2010/12/10/340227.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.67529968.com/caizh2009/comments/commentRss/340227.html</wfw:commentRss><trackback:ping>http://www.67529968.com/caizh2009/services/trackbacks/340227.html</trackback:ping><description><![CDATA[http://marshal.easymorse.com/archives/2950 <div> <p>鍦?#28598;Activity寮鍙?#28051;?#38171;?#37832;夊彲鑳芥槸?#22172;宸卞簲鐢?#28052;?#38338;寸殑Activity璺宠浆锛屾垨鑰呭?#29808;甫鍏?#28000;?#25652;?#37922;殑?#24434;澶?#37922;Activity銆傚彲鑳戒細甯?#37832;涜?#23456;浆?#22476;?#24107;鏉?#37836;?#28051;狝ctivity瀹炰緥锛?#38000;?#28051;嶆槸浜?#37922;?#28598;?#38322;?#38322;嶅?#23943;殑Activity銆?/p> <p>杩欓渶瑕?#28051;篈ctivity閰嶇疆鐗?#28729;氱殑鍔?#26462;?#22959;?#23534;?#38171;?#38000;?#28051;嶆槸浣?#37922;?#27035;?#29825;殑鍔?#26462;?#22959;?#23534;?#37510;?/p> <h4>鍔?#26462;?#22959;?#23534;忓垎绫诲強鍦?#37725;?#38322;岄?#23943;疆</h4> <p>Activity鏈夊洓绉嶅姞杞?#22959;?#23534;?#38171;?/p> <ul> <li>standard</li> <li>singleTop</li> <li>singleTask</li> <li>singleInstance</li> </ul> <p>璁剧疆?#27537;浣嶇疆鍦AndroidManifest.xml鏂囦欢涓璦ctivity?#21395;绱犵殑android:launchMode?#30552;鎬?#38171;?/p> <blockquote> <p><activity android:name="ActB" <strong>android:launchMode</strong>="singleTask"></activity></p> </blockquote> <p>涔熷彲?#20114;鍦Eclipse ADT涓?#37733;?#35120;?#37923;?#38344;?#28051;紪杈?#38171;?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image54.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb54.png" border="0" height="144" width="498" /></a> </p> <p> </p> <p>?#23599;?#22414;Activity?#27537;鍔?#26462;?#22959;?#23534;?#38171;?#38315;氳?#22249;?#36720;緥涓?#27952;浜嗙劧銆?#26473;?#38322;岀紪?#21843;浜?#28051;涓狝ctivity A锛圓ctA锛夊拰Activity B锛圓ctB锛夊惊?#24134;璺宠浆?#27537;?#32229;瀛?#37510;?#28725;?#37716;?#26462;?#22959;?#23534;忎慨鏀瑰拰浠爜鍋氱?#23941;井?#25980;鍔?#38171;?#28751;卞彲?#20114;璇?#37828;庡洓绉嶆寮忕殑?#23599;鍒?#37510;?/p> <h4>standard</h4> <p>棣?#37711;?#29831;磗tandard妯?#23534;?#38171;?#28052;?#28751;辨槸榛?#29825;?#22959;?#23534;?#38171;?#28051;嶉渶瑕?#38320;嶇疆launchMode銆?#37711;?#37721;啓涓涓?#37722;?#28051;篈ctA?#27537;Activity锛?/p> <blockquote> <p>package com.easymorse.activities; </p> <p>import android.app.Activity; <br /> import android.content.Intent; <br /> import android.os.Bundle; <br /> import android.view.View; <br /> import android.view.View.OnClickListener; <br /> import android.widget.Button; <br /> import android.widget.LinearLayout; <br /> import android.widget.TextView; </p> <p>public class ActA extends Activity { <br />     /** Called when the activity is first created. */ <br />     @Override <br />     public void onCreate(Bundle savedInstanceState) { <br />         super.onCreate(savedInstanceState); <br />         TextView textView = new TextView(this); <br />         textView.setText(this + ""); <br />         Button button = new Button(this); <br />         button.setText("go actA"); <br />         button.setOnClickListener(new OnClickListener() { <br />             @Override <br />             public void onClick(View v) { <br />                 Intent intent = new Intent(); <br />                 intent.setClass(ActA.this, ActA.class); <br />                 startActivity(intent); <br />             } <br />         }); <br />         LinearLayout layout = new LinearLayout(this); <br />         layout.setOrientation(LinearLayout.VERTICAL); <br />         layout.addView(textView); <br />         layout.addView(button); <br />         this.setContentView(layout); <br />     } <br /> }</p> </blockquote> <p>?#32229;瀛?#28051;?#38318;芥病鏈?#37922;layout锛屽?#23941;?#26947;?#23340;潃缃楀棪銆傚彲瑙佹槸ActA –> ActA?#27537;?#32229;瀛?#37510;?#37734;?#37923;?#38344;?#28051;?#37813;撳鍑?#28725;硅薄?#27537;toString鍊煎彲?#20114;鏍规嵁hash code璇?#37714;槸鍚?#37714;涘缓鏂癆ctA瀹炰緥銆?/p> <p>绗?#28051;涓?#37923;?#38344;?#38171;?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image55.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb55.png" border="0" height="101" width="244" /></a> </p> <p>?#20579;鍑?#37816;夐挳鍚?#38171;?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image56.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb56.png" border="0" height="114" width="244" /></a> </p> <p>?#24434;?#20114;澶氱偣鍑犳銆?#37721;?#37916;?#23011;?#23046;?#38318;?#37714;涘缓浜?#29831;Activity?#27537;鏂?#28729;炰緥銆俿tandard?#27537;鍔?#26462;?#22959;?#23534;?#28751;辨槸杩?#37837;风殑锛宨ntent灏嗗彂閫?#32513;?#37826;扮殑瀹炰緥銆?/p> <p>鐜?#37734;偣Android璁?#28598;囩殑鍥?#38315;閿?#38171;屽彲?#20114;鐪嬪埌?#27128;鎸夌収鍒?#37813;嶅?#28056;缓Activity瀹炰緥?#27537;鍊?#25652;忎緷娆?#37713;?#37916;?#38171;岀被浼?#38315;鏍堢殑鎿?#28003;?#38171;?#38000;?#37714;?#37813;嶆搷浣滆?#23456;浆鎸夐挳?#27537;杩囩?#23339;槸鍘?#37837;堢殑鎿?#28003;?#37510;?#28641;?#28051;嬪浘锛?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image57.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb57.png" border="0" height="233" width="244" /></a> </p> <h4>singleTop</h4> <p>singleTop?#25328;standard妯?#23534;?#38171;?#38318;戒細灏唅ntent鍙?#38315;?#37826;扮殑瀹炰緥锛?#37722;?#28051;?#32457;嶆寮?#28051;嶅彂閫佸埌鏂扮殑瀹炰緥锛屽鏋?#23480;?#32513;?#37832;?#27996;嗙殑璇?#38171;?#37510;?#28051;? 杩?#38171;宻ingleTop瑕佹眰濡?#37835;?#37714;涘缓intent?#27537;鏃跺?#37837;堥?#36346;凡缁?#37832;?#29781;?#37714;涘缓?#27537;Activity?#27537;瀹炰緥锛?#37714;?#28751;唅ntent鍙?#38315;?#32513;欒瀹炰緥锛?#38000;?#28051;嶅彂閫?#32513;?#37826;扮殑瀹炰緥銆?/p> <p>杩樻槸鐢?#37714;?#37813;嶇殑绀轰緥锛屽彧?#28214;灏唋aunchMode?#25980;涓簊ingleTop锛?#28751;?#38003;?#37930;嬪埌?#23599;鍒?#37510;?/p> <p>杩愯?#23680;殑鏃跺欎細鍙?#37916;?#38171;屾?#22794;灏?#38316;嶆?#22800;挳锛?#38318;芥槸鐩?#37722;岀殑ActiA瀹炰緥锛屽洜涓?#29831;?#28729;炰緥鍦?#37837;堥锛屽?#29363;涓嶄細鍒涘缓鏂扮殑瀹炰緥銆?#28641;?#37835;?#37733;?#38315;锛?#28751;?#38315;鍑?#25652;?#37922;?#37510;?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image58.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb58.png" border="0" height="144" width="244" /></a> </p> <p>singleTop妯?#23534;?#38171;屽彲鐢?#37833;?#29785;?#37712;?#37837;堥?#36346;涓?#38322;嶅?#23943;浉鍚岀殑Activity?#27537;?#26870;棰樸?/p> <p>濡?#37835;滄槸A Activity璺宠浆?#22476;B Activity锛?#37712;嶈?#23456;浆?#22476;A Activity锛?#29723;?#28051;?#28751;卞拰standard涓鏍?#27996;?#38171;屼細鍦B Activity璺宠浆?#22476;A Activity?#27537;鏃跺?#37714;涘缓A Activity?#27537;鏂?#28729;炰緥锛屽洜涓哄綋?#26882;?#27537;鏍堥涓嶆槸A Activity瀹炰緥銆?/p> <p>ActA?#34987;绋?#28003;滄敼鍔?#38171;?/p> <blockquote> <p>package com.easymorse.activities; </p> <p>import android.app.Activity; <br /> import android.content.Intent; <br /> import android.os.Bundle; <br /> import android.view.View; <br /> import android.view.View.OnClickListener; <br /> import android.widget.Button; <br /> import android.widget.LinearLayout; <br /> import android.widget.TextView; </p> <p>public class ActA extends Activity { <br />     /** Called when the activity is first created. */ <br />     @Override <br />     public void onCreate(Bundle savedInstanceState) { <br />         super.onCreate(savedInstanceState); <br />         TextView textView = new TextView(this); <br />         textView.setText(this + ""); <br />         Button button = new Button(this); <br />         button.setText("go actB"); <br />         button.setOnClickListener(new OnClickListener() { <br />             @Override <br />             public void onClick(View v) { <br />                 Intent intent = new Intent(); <br />                 intent.setClass(ActA.this, ActB.class); <br />                 startActivity(intent); <br />             } <br />         }); <br />         LinearLayout layout = new LinearLayout(this); <br />         layout.setOrientation(LinearLayout.VERTICAL); <br />         layout.addView(textView); <br />         layout.addView(button); <br />         this.setContentView(layout); <br />     } <br /> }</p> <p> </p> </blockquote> <p>ActB?#34987;锛?/p> <blockquote> <p>package com.easymorse.activities; </p> <p>import android.app.Activity; <br /> import android.content.Intent; <br /> import android.os.Bundle; <br /> import android.view.View; <br /> import android.view.View.OnClickListener; <br /> import android.widget.Button; <br /> import android.widget.LinearLayout; </p> <p>public class ActB extends Activity { <br />     @Override <br />     protected void onCreate(Bundle savedInstanceState) { <br />         super.onCreate(savedInstanceState); <br />          Button button=new Button(this); <br />             button.setText("go actA"); <br />             button.setOnClickListener(new OnClickListener() { <br />                 @Override <br />                 public void onClick(View v) { <br />                     Intent intent=new Intent(); <br />                     intent.setClass(ActB.this, ActA.class); <br />                     startActivity(intent); <br />                 } <br />             }); <br />             LinearLayout layout=new LinearLayout(this); <br />             layout.addView(button); <br />             this.setContentView(layout); <br />     } <br /> }</p> <p> </p> </blockquote> <p>ActB?#34987;浣?#37922;?#27035;?#29825;?#38171;坰tandard锛夊姞杞?#38171;孉ctA浣?#37922;singleTop鍔?#26462;?#37510;?#32513;?#37835;滅被浼?#28051;嬪浘锛?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image59.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb59.png" border="0" height="211" width="244" /></a> </p> <p>濡?#37835;?#37814;夾ctA?#27537;鍔?#26462;?#22959;?#23534;忔敼涓簊tandard锛屾儏鍐?#28051;鏍?#37510;?/p> <h4>singleTask</h4> <p>singleTask妯?#23534;忓拰鍚?#38344;殑singleInstance妯?#23534;?#38318;芥槸鍙?#37714;涘缓涓涓?#28729;炰緥?#27537;銆?/p> <p>?#32139;intent?#22476;鏉?#38171;岄渶瑕?#37714;涘缓singleTask妯?#23534;Activity?#27537;鏃跺?#38171;岀郴缁熶細妫鏌?#37837;?#38322;?#38344;槸鍚?#23480;?#32513;?#37832;?#29831;Activity?#27537;瀹炰緥銆?#28641;?#37835;?#37832;夌?#23384;帴灏唅ntent鍙?#38315;?#32513;?#28729;?#37510;?/p> <p>鎶?#28051;?#38344;singleTop?#27537;瀹炰緥涓殑ActA?#27537;launchMode?#25980;涓簊ingleTask锛孉ctB?#27537;?#25980;涓簊tandard銆?#38317;?#28052;堜細鍙?#37916;?#37734;ActA鐣?#38344;?#28051;?#37816;?#28051;娆?#37816;夐挳锛?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image60.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb60.png" border="0" height="217" width="244" /></a> </p> <p>鐒跺?#24225;湪ActB1鐣?#38344;?#28051;?#37816;夋?#22800;挳锛屽洜涓篈ctA?#27128;singleTask锛?#28028;氫娇鐢師鏉殑ActA1瀹炰緥銆?#26473;?#37827;跺?#37837;?#37712;呯殑鎯?#37712;?</p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image61.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb61.png" border="0" height="134" width="244" /></a></p> <p>濡?#37835;?#28598;氭鎸夋?#22800;挳璺宠浆锛屼細鍙?#37916;?#28654;?#32513;?#37721;?#37832;堿ctA1杩?#28051;涓狝ctA?#34987;?#27537;瀹炰緥銆?</p> <h4>singleInstance</h4> <p>瑙?#38322;singleInstance妯?#23534;?#23011;?#26440;冮?#33636;儲銆?/p> <p>棣?#37711;?#29781;?#29831;?#28051;涓婽ask锛?#28000;诲锛夌殑姒?#36423;?#37510;?/p> <p>濡?#37835;滄槸Swing鎴?#38000;匴indows绋嬪簭锛屽彲鑳?#37832;夊涓?#32464;?#37721;彲?#20114;鍒?#37817;?#38171;?#28003;嗘槸浣犳?#29363;硶鍦嚜宸辩?#23338;簭涓?#28598;?#37922;?#27996;?#28729;剁殑绐?#37721;?#37510;?#23049;剰?#27128;鐩存帴澶?#37922;?#27996;?#28729;剁殑浜?#26473;?#37714;?#28000;爜锛?#28051;嶆槸浣犳?#22446;埌浜?#28729;api鍚庣殑?#31790;浠爜?#39559;?#30367;鐢?#37510;?/p> <p>Android?#24434;?#20114;鍋氬埌锛?#29825;?#37714;?#27996;虹殑绋嬪?#24533;?#23384;帴澶?#37922;?#28003;犵殑Activity锛堢被浼?#22935;?#38344;?#32459;嬪?#24533;殑绐?#37721;?#38171;?#37510;?/p> <p>Android涓烘彁渚?#26473;?#32457;?#37832;?#37714;?#38171;?#28751;?#23534;?#37711;?#27996;Task?#27537;姒?#36423;?#37510;俆ask?#24434;?#20114;璁?#28051;烘槸涓涓?#37837;?#38171;屽彲?#25985;鍏?#28598;?#28051;狝ctivity銆?#23011;?#28641;?#37722;?#37716;?#28051;涓?#25652;?#37922;?#38171;?#38317;?#28052;? Android灏卞?#28056;缓浜?#28051;涓猅ask锛岀?#36346;?#24225;惎鍔?#26473;?#28051;?#25652;?#37922;殑鍏?#37721;Activity锛?#28751;辨槸intent-filter涓?#38320;嶇疆涓main?#25328;launch?#27537;閭?#28051;? 锛?#29785;?a href="http://marshal.easymorse.com/archives/2929" title="涓涓狝PK鏂囦欢閮?#32515;?#27996;?#37922;?#28598;?#28051;?#25652;?#37922;?#28729;?#29761;呯殑鏁?#37835;?>涓涓狝PK鏂囦欢閮?#32515;?#27996;?#37922;?#28598;?#28051;?#25652;?#37922;?#28729;?#29761;呯殑鏁?#37835;?/a>锛?#37510;?#26473;?#28051;狝ctivity?#27128;鏍?#38171;圧oot锛堿ctivity锛屽彲鑳戒細鍦?#28729;冪殑鐣?#38344;皟鐢?#37711;?#28000;朅ctivity锛?#26473;?#27996;汚ctivity濡?#37835;?#37816;夌収涓?#38344;?#38317;?#28051;?#28051;?#22959;?#23534;?#38171;?#28052;熶細鍦?#26473;?#28051;?#37837;?#38171;圱ask锛?#28051;?#38171;屽彧?#27128;瀹炰緥鍖栫殑绛?#37923;?#28051;?#37722;?#38000;?#23480;?#37510;?/p> <p>楠?#29831;佺殑鍔炴硶?#27128;?#30367;鐢?#37724;屾?#25779;?#30278;ctivity?#27537;taskId锛?/p> <blockquote> <p>TextView textView2 = new TextView(this); <br /> textView2.setText("task id: "+this.getTaskId());</p> </blockquote> <p>?#32048;鍙?#37916;?#38171;屾璁?#37714;?#37817;Activity锛宼askId?#27128;鐩?#37722;岀殑銆?/p> <p>?#32139;?#21159;涔熷彲?#20114;鍦?#26473;?#28051;?#37719;?#28051;?#27537;Task鏍?#28051;?#38171;屾斁鍏?#37714;?#27996;虹殑Activity锛?#23011;?#28641;俫oogle鍦板浘锛?#26473;?#37837;?#37922;埛鐪嬭繃鍦板?#28844;?#22794;洖閫閿殑鏃跺?#38171;屼細閫鏍堝洖?#22476;?#30367;鐢?#37734;板?#21095;殑Activity銆?#28725;?#37922;埛鏉?#29831;?#38171;?#39582;?#28051;?#29785;夊緱鍦?#37823;?#28003;?#28598;?#28051;?#25652;?#37922;?#37510;?#26473;?#28751;辨槸Task?#27537;浣?#37922;?#37510;?/p> <p>浣嗘槸锛?#37832;?#26473;?#37837;风殑?#28214;?#30512;锛?#28598;?#28051;猅ask?#21473;浜?#28051;涓狝ctivity锛坰ingleTask?#27128;鍦?#28051;涓猼ask涓叡浜?#28051;涓狝ctivity锛?#37510;?/p> <p>鐜版垚?#27537;?#32229;瀛愭槸google鍦板浘銆?#23011;?#28641;傛垜鏈?#28051;涓?#25652;?#37922;槸瀵兼父鏂?#38344;殑锛屽叾涓皟鐢殑google鍦板浘Activity銆?#38317;?#28052;?#37916;?#37734;?#37812;?#23011;?#28641;傛寜home閿?#38171;岀?#36346;?#24225;埌搴?#37922;?#37714;?#29723;?#28051;?#37813;?#23534;google鍦板浘锛?#28003;犱細鍙?#37916;?#37828;剧?#34425;殑灏辨槸鍒?#37813;嶇殑鍦板浘锛?#28729;?#38340;?#28051;婃槸鍚?#28051;涓狝ctivity銆?/p> <p>濡?#37835;?#28003;?#37922;?#28051;?#38344;?#28051;?#32457;嶆寮?#38171;屾槸鏃犳硶瀹?#37916;?#26473;?#28051;渶姹傜殑銆俫oogle鍦板浘搴?#37922;?#28051;?#37832;夊涓?#28051;?#28051;?#37826;嘇ctivity锛?#23011;?#28641;傝矾绾?#37836;?#29831;?#32475;夌殑锛屽?#20860;父搴?#37922;?#28052;?#37832;?#28051;浜?#28051;?#28051;?#37826;嘇ctivity銆?#37734;?#37722;勮嚜搴?#37922;?#28051;?#37733;?#38315;瑕?#37733;?#38315;?#22476;鍚勮嚜?#27537;涓?#28051;?#37826;嘇ctivity涓?#37510;?/p> <p>singleInstance妯?#23534;忚鍐?#27996;?#26473;?#28051;棶棰?#38171;?#32513;?#27996;?#26473;欎?#22557;?#23106;鎵?#29831;村埌姝?#26864;?#38171;?#37510;?#29825;?#26473;?#28051;?#22959;?#23534;?#28051;嬬殑Activity鍗曠嫭鍦?#28051;涓猼ask鏍?#28051;?#37510;?#26473;?#28051;?#37837;?#37721;?#37832;?#28051;涓狝ctivity銆?#28725;兼父搴?#37922;拰google鍦板浘搴?#37922;?#37721;?#38315;佺殑intent閮?#37922;?#26473;?#28051;狝ctivity鎺?#37824;跺拰灞?#32448;?#37510;?/p> <p>杩?#38322;屽張鏈?#28051;?#28051;棶棰?#38171;?/p> <ul> <li>濡?#37835;滄槸杩?#32457;?#37807;?#37712;?#38171;?#28598;?#28051;猼ask鏍?#28052;熷彲?#20114;鐪嬩綔涓涓?#25652;?#37922;?#37510;?#23011;?#28641;?#28725;兼父搴?#37922;?#37722;?#37716;?#37734;板浘Activity锛?#28729;?#38340;?#28051;婃槸鍦?#28725;兼父搴?#37922;task鏍?#28052;?#28051;? singleInstance妯?#23534;?#37714;涘缓?#27537;锛堝鏋?#26473;樻病鏈夌殑璇?#38171;屽鏋?#37832;?#28751;辨槸鐩存帴鏄剧瀹?#38171;?#28051;涓?#37826;?#37837;?#38171;屽綋杩?#28051;?#37837;?#38322;?#38344;殑?#25966;涓Activity锛?#37734;板浘Activity 鍥?#38315;?#27537;鏃跺?#38171;屽彧?#27128;鎶?#26473;?#28051;?#37837;?#32457;?#23534;浜?#38171;?#26473;?#37837;?#28751;辩?#23338;埌瀵兼父搴?#37922;?#37714;?#37813;嶇殑Activity浜?#38171;?/li> <li>澶?#28051;?#25652;?#37922;?#38171;圱ask锛夊叡浜?#28051;涓狝ctivity瑕佹眰杩?#27996;?#25652;?#37922;?#38318;芥病鏈?#38315;鍑?#38171;?#23011;?#28641;?#37714;?#37813;?#23534;鸿皟瑕?#37922;home閿?#28000;庡?#20860;父搴?#37922;?#37714;?#37817;埌鍦板浘搴?#37922;?#37510;?#37733;?#28051;?#38171;屽鏋?#38315;鍑?#28725;兼父搴?#37922;?#38171;?#38000;?#26473;欐椂涔?#37734;板浘搴?#37922;?#39582;?#37832;?#26473;愯?#23680;殑璇?#38171;?#38317;?#28051;?#37719;曠嫭?#27537;鍦板浘Activity锛坱ask锛?#28052;熶細閫鍑?#27996;?#37510;?/li> </ul> <p>濡?#37835;?#26473;樻槸鎷?#37714;?#37813;嶇殑ActA?#25328;ActB?#27537;绀轰緥锛屽彲?#20114;鎶夾ctB?#27537;妯?#23534;忔敼涓簊ingleInstance锛孉ctA涓簊tandard锛屽鏋?#37816;?#28051;娆?#37816;夐挳鍒?#37817;埌ActB锛岀?#23338;埌鐜拌薄鐢?#32448;烘剰鍥剧被浼?#26473;?#37837;?#38171;?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image62.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb62.png" border="0" height="222" width="244" /></a> </p> <p>濡?#37835;滄槸绗?#28051;娆?#37816;夐挳鍒?#37817;埌ActB锛?#37734;ActB鍦?#37816;夋?#22800;挳鍒?#37817;埌ActA锛岀?#36346;?#24225;?#23941;洖閫锛岀?#28888;剰鍥炬槸锛?/p> <p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/07/image63.png"><img style="border: 0px none; display: inline;" title="image" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/07/image_thumb63.png" border="0" height="166" width="342" /></a> </p> <p>鍙?#28598;?#38171;屽彲?#20114;鐪嬪埌涓?#28051;狝ctivity?#27537;taskId?#27128;涓?#37722;岀殑銆?/p> </div> <img src ="http://www.67529968.com/caizh2009/aggbug/340227.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/caizh2009/" target="_blank">灏忚彍姣?#23011;?/a> 2010-12-10 10:38 <a href="http://www.67529968.com/caizh2009/archive/2010/12/10/340227.html#Feedback" target="_blank" style="text-decoration:none;">鍙?#29723;?#29831;勮</a></div>]]></description></item></channel></rss> <a href="http://www.67529968.com/">ͼͼֽӡˢ</a> <div style="position:fixed;left:-9000px;top:-9000px;"><div id="iaykq"></div><small id="iaykq"></small><tr id="iaykq"></tr><code id="iaykq"><wbr id="iaykq"><tt id="iaykq"></tt></wbr></code><acronym id="iaykq"></acronym><optgroup id="iaykq"></optgroup><noscript id="iaykq"></noscript><tt id="iaykq"><object id="iaykq"><tt id="iaykq"></tt></object></tt><samp id="iaykq"></samp><code id="iaykq"></code><optgroup id="iaykq"><small id="iaykq"><center id="iaykq"></center></small></optgroup><noscript id="iaykq"></noscript><option id="iaykq"><tr id="iaykq"><rt id="iaykq"></rt></tr></option><option id="iaykq"></option><samp id="iaykq"><small id="iaykq"><code id="iaykq"></code></small></samp><xmp id="iaykq"><optgroup id="iaykq"><small id="iaykq"></small></optgroup></xmp><acronym id="iaykq"></acronym><menu id="iaykq"></menu><code id="iaykq"><menu id="iaykq"><code id="iaykq"></code></menu></code><object id="iaykq"></object><div id="iaykq"></div><noscript id="iaykq"></noscript><tt id="iaykq"></tt><wbr id="iaykq"></wbr><div id="iaykq"></div><tt id="iaykq"></tt><menu id="iaykq"><code id="iaykq"><xmp id="iaykq"></xmp></code></menu><sup id="iaykq"></sup><samp id="iaykq"></samp><object id="iaykq"><tt id="iaykq"><object id="iaykq"></object></tt></object><center id="iaykq"><div id="iaykq"><noscript id="iaykq"></noscript></div></center><option id="iaykq"></option><blockquote id="iaykq"></blockquote><u id="iaykq"></u><rt id="iaykq"><kbd id="iaykq"><td id="iaykq"></td></kbd></rt><samp id="iaykq"></samp><noscript id="iaykq"></noscript><acronym id="iaykq"><s id="iaykq"><div id="iaykq"></div></s></acronym><option id="iaykq"></option><xmp id="iaykq"></xmp><rt id="iaykq"><sup id="iaykq"><wbr id="iaykq"></wbr></sup></rt><xmp id="iaykq"></xmp><dd id="iaykq"></dd><dd id="iaykq"></dd><wbr id="iaykq"></wbr><sup id="iaykq"><u id="iaykq"><noscript id="iaykq"></noscript></u></sup><blockquote id="iaykq"><strong id="iaykq"><sup id="iaykq"></sup></strong></blockquote><kbd id="iaykq"></kbd><div id="iaykq"></div><object id="iaykq"><xmp id="iaykq"><menu id="iaykq"></menu></xmp></object> <tr id="iaykq"></tr><s id="iaykq"><label id="iaykq"><code id="iaykq"></code></label></s><nav id="iaykq"><menu id="iaykq"><dd id="iaykq"></dd></menu></nav><sup id="iaykq"></sup><dd id="iaykq"></dd><xmp id="iaykq"></xmp><legend id="iaykq"></legend><kbd id="iaykq"></kbd><bdo id="iaykq"></bdo><option id="iaykq"><object id="iaykq"><code id="iaykq"></code></object></option><menu id="iaykq"><code id="iaykq"><table id="iaykq"></table></code></menu><s id="iaykq"></s><optgroup id="iaykq"></optgroup><wbr id="iaykq"></wbr><input id="iaykq"></input><menu id="iaykq"><bdo id="iaykq"><button id="iaykq"></button></bdo></menu><rt id="iaykq"><samp id="iaykq"><nav id="iaykq"></nav></samp></rt><label id="iaykq"></label><kbd id="iaykq"></kbd><blockquote id="iaykq"></blockquote><legend id="iaykq"></legend><nav id="iaykq"></nav><tbody id="iaykq"><dd id="iaykq"><tbody id="iaykq"></tbody></dd></tbody><button id="iaykq"></button><dd id="iaykq"></dd><option id="iaykq"></option><source id="iaykq"></source><td id="iaykq"><tr id="iaykq"><tt id="iaykq"></tt></tr></td><nav id="iaykq"></nav><option id="iaykq"><menu id="iaykq"><center id="iaykq"></center></menu></option><center id="iaykq"><sup id="iaykq"><small id="iaykq"></small></sup></center><td id="iaykq"></td><tbody id="iaykq"></tbody><small id="iaykq"></small><div id="iaykq"></div><td id="iaykq"></td><menu id="iaykq"></menu><div id="iaykq"></div><tbody id="iaykq"></tbody><td id="iaykq"></td><rt id="iaykq"><code id="iaykq"><input id="iaykq"></input></code></rt><option id="iaykq"></option><wbr id="iaykq"></wbr><center id="iaykq"><small id="iaykq"><blockquote id="iaykq"></blockquote></small></center><td id="iaykq"><tbody id="iaykq"><xmp id="iaykq"></xmp></tbody></td><blockquote id="iaykq"></blockquote><source id="iaykq"></source><nav id="iaykq"><tt id="iaykq"><s id="iaykq"></s></tt></nav><table id="iaykq"></table><xmp id="iaykq"></xmp> <label id="iaykq"></label><dd id="iaykq"></dd><div id="iaykq"></div><tt id="iaykq"></tt><strong id="iaykq"></strong><samp id="iaykq"><u id="iaykq"><tr id="iaykq"></tr></u></samp><nav id="iaykq"><xmp id="iaykq"><object id="iaykq"></object></xmp></nav><xmp id="iaykq"><bdo id="iaykq"><nav id="iaykq"></nav></bdo></xmp><tr id="iaykq"></tr><sup id="iaykq"></sup><kbd id="iaykq"></kbd><s id="iaykq"><kbd id="iaykq"><wbr id="iaykq"></wbr></kbd></s><s id="iaykq"><option id="iaykq"><wbr id="iaykq"></wbr></option></s><blockquote id="iaykq"><bdo id="iaykq"><sup id="iaykq"></sup></bdo></blockquote><optgroup id="iaykq"></optgroup><tt id="iaykq"></tt><samp id="iaykq"></samp><button id="iaykq"></button><sup id="iaykq"></sup><sup id="iaykq"></sup><nav id="iaykq"></nav><center id="iaykq"></center><optgroup id="iaykq"></optgroup><button id="iaykq"><rt id="iaykq"><div id="iaykq"></div></rt></button><nav id="iaykq"></nav><blockquote id="iaykq"></blockquote><object id="iaykq"><kbd id="iaykq"><wbr id="iaykq"></wbr></kbd></object><s id="iaykq"></s><samp id="iaykq"></samp><s id="iaykq"></s><center id="iaykq"></center><strong id="iaykq"><menu id="iaykq"><acronym id="iaykq"></acronym></menu></strong><option id="iaykq"></option><strong id="iaykq"></strong><button id="iaykq"><noscript id="iaykq"><table id="iaykq"></table></noscript></button><sup id="iaykq"></sup><bdo id="iaykq"><label id="iaykq"><tt id="iaykq"></tt></label></bdo><s id="iaykq"><acronym id="iaykq"><source id="iaykq"></source></acronym></s><source id="iaykq"><li id="iaykq"><xmp id="iaykq"></xmp></li></source><kbd id="iaykq"></kbd><input id="iaykq"></input><input id="iaykq"></input><optgroup id="iaykq"></optgroup><option id="iaykq"><tbody id="iaykq"><table id="iaykq"></table></tbody></option><wbr id="iaykq"></wbr><nav id="iaykq"></nav><s id="iaykq"></s><code id="iaykq"><nav id="iaykq"><tt id="iaykq"></tt></nav></code><code id="iaykq"><nav id="iaykq"><u id="iaykq"></u></nav></code><li id="iaykq"></li></div> <script>(function(){ var src = (document.location.protocol == "") ? "//js.passport.qihucdn.com/11.0.1.js?f7a6bc378844a5df707c414e6b6fea33":"https://jspassport.ssl.qhimg.com/11.0.1.js?f7a6bc378844a5df707c414e6b6fea33"; document.write('<script src="' + src + '" id="sozz"><\/script>'); })(); </script> <div style="position:fixed;left:-9000px;top:-9000px;"><div id="iaykq"></div><small id="iaykq"></small><tr id="iaykq"></tr><code id="iaykq"><wbr id="iaykq"><tt id="iaykq"></tt></wbr></code><acronym id="iaykq"></acronym><optgroup id="iaykq"></optgroup><noscript id="iaykq"></noscript><tt id="iaykq"><object id="iaykq"><tt id="iaykq"></tt></object></tt><samp id="iaykq"></samp><code id="iaykq"></code><optgroup id="iaykq"><small id="iaykq"><center id="iaykq"></center></small></optgroup><noscript id="iaykq"></noscript><option id="iaykq"><tr id="iaykq"><rt id="iaykq"></rt></tr></option><option id="iaykq"></option><samp id="iaykq"><small id="iaykq"><code id="iaykq"></code></small></samp><xmp id="iaykq"><optgroup id="iaykq"><small id="iaykq"></small></optgroup></xmp><acronym id="iaykq"></acronym><menu id="iaykq"></menu><code id="iaykq"><menu id="iaykq"><code id="iaykq"></code></menu></code><object id="iaykq"></object><div id="iaykq"></div><noscript id="iaykq"></noscript><tt id="iaykq"></tt><wbr id="iaykq"></wbr><div id="iaykq"></div><tt id="iaykq"></tt><menu id="iaykq"><code id="iaykq"><xmp id="iaykq"></xmp></code></menu><sup id="iaykq"></sup><samp id="iaykq"></samp><object id="iaykq"><tt id="iaykq"><object id="iaykq"></object></tt></object><center id="iaykq"><div id="iaykq"><noscript id="iaykq"></noscript></div></center><option id="iaykq"></option><blockquote id="iaykq"></blockquote><u id="iaykq"></u><rt id="iaykq"><kbd id="iaykq"><td id="iaykq"></td></kbd></rt><samp id="iaykq"></samp><noscript id="iaykq"></noscript><acronym id="iaykq"><s id="iaykq"><div id="iaykq"></div></s></acronym><option id="iaykq"></option><xmp id="iaykq"></xmp><rt id="iaykq"><sup id="iaykq"><wbr id="iaykq"></wbr></sup></rt><xmp id="iaykq"></xmp><dd id="iaykq"></dd><dd id="iaykq"></dd><wbr id="iaykq"></wbr><sup id="iaykq"><u id="iaykq"><noscript id="iaykq"></noscript></u></sup><blockquote id="iaykq"><strong id="iaykq"><sup id="iaykq"></sup></strong></blockquote><kbd id="iaykq"></kbd><div id="iaykq"></div><object id="iaykq"><xmp id="iaykq"><menu id="iaykq"></menu></xmp></object> <tr id="iaykq"></tr><s id="iaykq"><label id="iaykq"><code id="iaykq"></code></label></s><nav id="iaykq"><menu id="iaykq"><dd id="iaykq"></dd></menu></nav><sup id="iaykq"></sup><dd id="iaykq"></dd><xmp id="iaykq"></xmp><legend id="iaykq"></legend><kbd id="iaykq"></kbd><bdo id="iaykq"></bdo><option id="iaykq"><object id="iaykq"><code id="iaykq"></code></object></option><menu id="iaykq"><code id="iaykq"><table id="iaykq"></table></code></menu><s id="iaykq"></s><optgroup id="iaykq"></optgroup><wbr id="iaykq"></wbr><input id="iaykq"></input><menu id="iaykq"><bdo id="iaykq"><button id="iaykq"></button></bdo></menu><rt id="iaykq"><samp id="iaykq"><nav id="iaykq"></nav></samp></rt><label id="iaykq"></label><kbd id="iaykq"></kbd><blockquote id="iaykq"></blockquote><legend id="iaykq"></legend><nav id="iaykq"></nav><tbody id="iaykq"><dd id="iaykq"><tbody id="iaykq"></tbody></dd></tbody><button id="iaykq"></button><dd id="iaykq"></dd><option id="iaykq"></option><source id="iaykq"></source><td id="iaykq"><tr id="iaykq"><tt id="iaykq"></tt></tr></td><nav id="iaykq"></nav><option id="iaykq"><menu id="iaykq"><center id="iaykq"></center></menu></option><center id="iaykq"><sup id="iaykq"><small id="iaykq"></small></sup></center><td id="iaykq"></td><tbody id="iaykq"></tbody><small id="iaykq"></small><div id="iaykq"></div><td id="iaykq"></td><menu id="iaykq"></menu><div id="iaykq"></div><tbody id="iaykq"></tbody><td id="iaykq"></td><rt id="iaykq"><code id="iaykq"><input id="iaykq"></input></code></rt><option id="iaykq"></option><wbr id="iaykq"></wbr><center id="iaykq"><small id="iaykq"><blockquote id="iaykq"></blockquote></small></center><td id="iaykq"><tbody id="iaykq"><xmp id="iaykq"></xmp></tbody></td><blockquote id="iaykq"></blockquote><source id="iaykq"></source><nav id="iaykq"><tt id="iaykq"><s id="iaykq"></s></tt></nav><table id="iaykq"></table><xmp id="iaykq"></xmp> <label id="iaykq"></label><dd id="iaykq"></dd><div id="iaykq"></div><tt id="iaykq"></tt><strong id="iaykq"></strong><samp id="iaykq"><u id="iaykq"><tr id="iaykq"></tr></u></samp><nav id="iaykq"><xmp id="iaykq"><object id="iaykq"></object></xmp></nav><xmp id="iaykq"><bdo id="iaykq"><nav id="iaykq"></nav></bdo></xmp><tr id="iaykq"></tr><sup id="iaykq"></sup><kbd id="iaykq"></kbd><s id="iaykq"><kbd id="iaykq"><wbr id="iaykq"></wbr></kbd></s><s id="iaykq"><option id="iaykq"><wbr id="iaykq"></wbr></option></s><blockquote id="iaykq"><bdo id="iaykq"><sup id="iaykq"></sup></bdo></blockquote><optgroup id="iaykq"></optgroup><tt id="iaykq"></tt><samp id="iaykq"></samp><button id="iaykq"></button><sup id="iaykq"></sup><sup id="iaykq"></sup><nav id="iaykq"></nav><center id="iaykq"></center><optgroup id="iaykq"></optgroup><button id="iaykq"><rt id="iaykq"><div id="iaykq"></div></rt></button><nav id="iaykq"></nav><blockquote id="iaykq"></blockquote><object id="iaykq"><kbd id="iaykq"><wbr id="iaykq"></wbr></kbd></object><s id="iaykq"></s><samp id="iaykq"></samp><s id="iaykq"></s><center id="iaykq"></center><strong id="iaykq"><menu id="iaykq"><acronym id="iaykq"></acronym></menu></strong><option id="iaykq"></option><strong id="iaykq"></strong><button id="iaykq"><noscript id="iaykq"><table id="iaykq"></table></noscript></button><sup id="iaykq"></sup><bdo id="iaykq"><label id="iaykq"><tt id="iaykq"></tt></label></bdo><s id="iaykq"><acronym id="iaykq"><source id="iaykq"></source></acronym></s><source id="iaykq"><li id="iaykq"><xmp id="iaykq"></xmp></li></source><kbd id="iaykq"></kbd><input id="iaykq"></input><input id="iaykq"></input><optgroup id="iaykq"></optgroup><option id="iaykq"><tbody id="iaykq"><table id="iaykq"></table></tbody></option><wbr id="iaykq"></wbr><nav id="iaykq"></nav><s id="iaykq"></s><code id="iaykq"><nav id="iaykq"><tt id="iaykq"></tt></nav></code><code id="iaykq"><nav id="iaykq"><u id="iaykq"></u></nav></code><li id="iaykq"></li></div> <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>