<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    如鵬網 大學生計算機學習社區

    CowNew開源團隊

    http://www.cownew.com 郵件請聯系 about521 at 163.com

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      363 隨筆 :: 2 文章 :: 808 評論 :: 0 Trackbacks
    BeanUtils
    BeanUtils是Apache-Commons項目提供的另一個非常方便的類庫,通過這個類庫能夠更方便的使用反射。最常用的類是BeanUtils(org.apache.commons.beanutils包中),使用這個類能通過名字訪問一個Bean中的某個屬性。
    通過BeanUtils.getProperty(person,”age”)能得到person的age屬性。此方法還支持內嵌對象,比如BeanUtils.getProperty(person,”manager.name”)就能得到person的manager屬性的name屬性。還支持List和Map類型的屬性,如下面的語法即可取得Order的顧客列表中第一個顧客的名字BeanUtils.getProperty(orderBean, "customers[1].name")。?使用BeanUtils.setProperty方法則可以設置javaBean的屬性值。
    ConstructorUtils提供了調用構造函數的方法,使用public static Object invokeConstructor(Class klass, Object arg)可以直接調用某個類的構造函數。
    MethodUtils提供了調用bean方法的方法,使用MethodUtils.invokeMethod(bean, methodName, parameter);可以直接調用某個類的某個方法。
    PropertyUtils提供了更詳細的屬性訪問方法,使用public static Class getPropertyType(Object bean, String name)獲取屬性的Class類型。
    UserInfo userInfo = (UserInfo) ConstructorUtils.invokeConstructor(
    ????UserInfo.class, new Object[] {});
    PersonInfo personInfo = (PersonInfo) ConstructorUtils
    ????.invokeConstructor(PersonInfo.class, new Object[] {});
    BeanUtils.setProperty(personInfo, "age", new Integer(20));
    BeanUtils.setProperty(personInfo, "name", "Tom");
    BeanUtils.setProperty(userInfo, "number", "admin");
    ??BeanUtils.setProperty(userInfo, "person", personInfo);
    System.out.println(BeanUtils.getProperty(userInfo, "person.name"));
    BeanUtils.setProperty(userInfo, "person.name","xdx");
    System.out.println(BeanUtils.getProperty(userInfo, "person.name"));
    System.out.println(PropertyUtils.getPropertyType(userInfo,"person"));
    運行結果:
    Tom
    xdx
    class com.cownew.PIS.basedata.common.PersonInfo
    posted on 2007-02-05 12:49 CowNew開源團隊 閱讀(765) 評論(1)  編輯  收藏

    評論

    # re: xjl:BeanUtils 2007-02-09 14:00 壞男孩
    ...................★
    ..................▍..★
    ..................▍.一 .☆
    ................. ▍ ..帆. ★
    ..................▍ ... 風. ☆
    ..................▍ ... ..順. ★
    ................. ▍.萬 事 如 意. ☆
    ..................▍☆ .★ .☆ .★. ☆
    ..................▍
     ..▍∵ ☆ ★...▍▍....█▍ ☆ ★∵▍..
       ◥█▅▅██▅▅██▅▅▅▅▅███◤
       .◥███████████████◤
     ~~~~◥█████████████◤~~~~
    ~~~~~~~~~~~~~~~~~~~~~~~~~  回復  更多評論
      


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 1区1区3区4区产品亚洲| 亚洲色WWW成人永久网址| 亚洲香蕉久久一区二区| 国产无人区码卡二卡三卡免费| 亚洲日本中文字幕| 最近中文字幕mv免费高清视频8| 亚洲国产精品无码久久SM| 成人性生交大片免费看好| 亚洲成在人线av| 亚洲美女免费视频| 亚洲熟女www一区二区三区| 天天拍拍天天爽免费视频| 欧洲亚洲综合一区二区三区| 亚洲国产精品毛片av不卡在线| 一级成人a做片免费| 亚洲va无码va在线va天堂| 永久免费av无码网站yy| 91情国产l精品国产亚洲区| 99久久久精品免费观看国产| 在线精品亚洲一区二区| 免费一级毛片在线播放不收费| 天堂亚洲免费视频| 亚洲AV无码精品无码麻豆| 国产高清免费视频| 国产亚洲蜜芽精品久久| 亚洲乱码无码永久不卡在线| 久久国产精品一区免费下载| 亚洲w码欧洲s码免费| 国产一区二区免费在线| 久久精品视频免费| 日韩亚洲国产综合高清| 亚洲婷婷国产精品电影人久久| 国产成人AV免费观看| 亚洲国产精品一区二区三区在线观看 | 国产亚洲成归v人片在线观看 | 最近中文字幕2019高清免费| 亚洲老熟女五十路老熟女bbw| 亚洲综合区小说区激情区 | 国产高清在线免费| 国产精品免费福利久久| 亚洲精品乱码久久久久久V|