<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                >### 1.出現特殊字符,可以使用 <![CDATA[]]> 把字面值包裹起來 ~~~ <bean id="d4" class="cn.li.lesson3.Dog"> <!-- 使用子節點和 <![CDATA[<小黑>]]>給value設置特殊字符--> <constructor-arg index="0"> <value><![CDATA[<小黑>]]></value> </constructor-arg> </bean> ~~~ >### 2.ref 引用其他的bean ~~~ <!-- 此時ref屬性的值 就是你要引用得bean的id... --> <property name="pet" ref="dog"></property> <!-- 或者 --> <property name="pet"> <ref bean="dog"></ref> (或者直接寫成<ref bean="dog"/>) </property> ~~~ >### 3.內部bean不需要設置任何 id 或 name 屬性 ,不能使用在任何其他地方 ~~~ <property name="pet"> <!-- 內部 Bean 聲明直接包含在 <property> 或 <constructor-arg> 元素里, 不需要設置任何 id 或 name 屬性 --> <bean class="com.igeek.demo3.Pet"> <property name="petName" value="小橘"></property> <property name="petType" value="貓"></property> </bean> </property> ~~~ >### 4.注入null值,使用<null/>標簽 ~~~ <constructor-arg name="name"> <null/> </constructor-arg> ~~~ >### 5.null值以及級聯屬性的注入 ~~~ <bean id="timo" class="com.igeek.demo3.Pet"> </bean> <!-- 添加有參構造器,不要忘記添加無參構造器 --> <bean id="xl" class="com.igeek.demo3.Person"> <constructor-arg name="name"> <null/> </constructor-arg> <constructor-arg name="age" value="20"></constructor-arg> <constructor-arg name="pet" ref="timo"></constructor-arg> <!-- 為級聯屬性賦值 。前提是上面的pet屬性不能為null --> <property name="pet.petName" value="提莫"></property> <property name="pet.petType" value="LOL"></property> </bean> ~~~ >### 6.配置集合類型的屬性(List,Array,Set) ~~~ <bean id="dog" class="com.igeek.demo4.Pet"> <property name="petName" value="大黃"></property> <property name="petType" value="犬"></property> </bean> <bean id="cat" class="com.igeek.demo4.Pet"> <property name="petName" value="小橘"></property> <property name="petType" value="貓"></property> </bean> <bean id="tom" class="com.igeek.demo4.Person"> <property name="pets"> <!-- 如果數據類型為數組,也是使用<list>標簽進行配置。 如果是Set集合,使用<set>標簽進行配置。 (里面內容的配置方式都相同。) --> <list> <ref bean="dog"/> <ref bean="cat"/> <null/> <bean id="snake" class="com.igeek.demo4.Pet"> <property name="petName" value="大象"></property> <property name="petType" value="蛇"></property> </bean> </list> </property> </bean> ~~~ >### 7.配置map類型 ~~~ <bean id="jack" class="com.igeek.demo4.Person"> <property name="map"> <map> <entry key="aa" value-ref="cat"></entry> <entry key="bb" value-ref="dog"></entry> </map> </property> </bean> ~~~ >### 8.配置properties類型 ~~~ <bean id="testpros" class="com.igeek.demo4.Person"> <property name="pros"> <props> <prop key="user">root</prop> <prop key="password">root123</prop> <prop key="jdbcUrl">jdbc:mysql:///test</prop> <prop key="driverClass">com.mysql.jdbc.Driver</prop> </props> </property> </bean> ~~~ >### 9.配置工具類集合 ~~~ <!-- 首先導入util命名空間 --> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd"> </beans> <util:list id="pets"> <ref bean="cat"/> <ref bean="dog"/> </util:list> <bean id="p4" class="cn.li.lesson5.Person"> <property name="pets"> <ref bean="pets"/> </property> </bean> ~~~ >### 10.使用p命名空間 ~~~ <!-- 首先導入p命名空間 --> xmlns:p="http://www.springframework.org/schema/p" <bean id="p1" class="cn.li.lesson6.Person" p:name="玨網" p:age="20" p:pet-ref="pet"> </bean> <bean id="pet" class="cn.li.lesson6.Pet"> <property name="name" value="鸚鵡"></property> <property name="type" value="鳥"></property> </bean> <!-- 使用p命名空間(spring 2.5版本引入的) 可以簡化bean的配置 --> ~~~ >### 11.自動裝配 ~~~ autowire = "byName" || "byType" 不推薦使用。 <!-- 可以通過autowire屬性設置bean的自動裝配 。 byName 根據bean的名字和bean,setter風格的屬性名進行自動裝配,如有匹配則自動裝配,沒有不裝配。 byType 根據bean的類型,和當前bean屬性的類型進行自動裝配。如果ioc容器有1個以上類型匹配的bean的時候,則會拋出異常。 constructor 當前bean中有多個構造器的時候 會很復雜不推薦使用該方式。 自動裝配的弊端。 1.autowire屬性是配置在bean級別的,如果只希望裝配個別屬性,則不夠靈活。 2.要么根據類型 要么根據名字自動裝配 不能兩個一起使用。 在使用spring整合第三方框架的時候 會使用autowire 。。。 --> <!-- <bean id="person" class="cn.li.lesson6.Person" p:name="tom" p:age="20" autowire="byType"></bean> <bean id="timo" class="cn.li.lesson6.Pet" p:name="豬八戒" p:type="pig"></bean> --> <bean id="p" class="cn.li.lesson6.Person" p:name="tom" p:age="20" autowire="byName"></bean> <bean id="pet" class="cn.li.lesson6.Pet" p:name="豬八戒" p:type="豬"></bean> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看