乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      spring通過(guò)構(gòu)造器的方式bean注入(方法二)

       魏祖清 2016-09-11
      Car類
      public class Car {
      private String brand;
      private String corp;
      private double price;
      private int maxSpend;
      public Car(String brand, String corp, double price) {
      super();
      this.brand = brand;
      this.corp = corp;
      this.price = price;
      }
      get和set方法......
      構(gòu)造器
      public Car(String brand, String corp, int maxSpend) {
      super();
      this.brand = brand;
      this.corp = corp;
      this.maxSpend = maxSpend;
      }

      @Override
      public String toString() {
      return "Car [brand=" + brand + ", corp=" + corp + ", price=" + price
      + ", maxSpend=" + maxSpend + "]";
      }
      }
      xml配置
      <!-- 通過(guò)構(gòu)造方法來(lái)配置bean的屬性 使用構(gòu)造器可以指定參數(shù)的位置和參數(shù)的類型,一區(qū)分重載的構(gòu)造器 -->
      <bean id="car" class="com.wzq.spring.bears.collection.Car">
      <constructor-arg value="Audi" index="0"></constructor-arg>
      <constructor-arg value="Shanghai" index="1"></constructor-arg>
      <constructor-arg value="30000" type="double"></constructor-arg>
      </bean>
      <bean id="car2" class="com.wzq.spring.bears.collection.Car">
      <constructor-arg value="Baoma" type="String"></constructor-arg>
      <constructor-arg type="String">
      <!-- value值可以直接配置 -->
      <!-- 如果包含特殊字符,使用<![CDATA[]]> -->
      <value><![CDATA[<^Shanghai^>]]></value>
      </constructor-arg>
      <constructor-arg value="300" type="int"></constructor-arg>
      </bean>
      main方法
      public class Mian {
      public static void main(String[] args) {
      ApplicationContext ctx = new ClassPathXmlApplicationContext(
      "applicationContext.xml");
      Car car = (Car) ctx.getBean("car");
      System.out.println(car);
      }
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多