首先,它是在org.apache.commons.beanutils.BeanUtils包中的一个方法。

方法的作用:用来将一些 key-value 的值(例如 hashmap)映射到 bean 中的属性。
 
servlet中有这样的使用:
先定义form表单内容的Info对象(当然你要先写一个bean,这个bean中包含form表单中各个对象的属性)
    InsuranceInfo info = new InsuranceInfo();  (这是一个javabean)
    BeanUtilities.populateBean(info, request);
——> populateBean(info, request.getParameterMap());(先将request内容转为Map类型)
——>BeanUtils.populate(info, propertyMap);(调用包中方法映射)
 
映射的过程就是将页面中的内容先用request获得,然后再将之转换为Map(这里用request.getParameterMap())
最后使用BeanUtils.populate(info,map)方法将页面各个属性映射到bean中。之后我们就可以这样使用bean.getXxxx()来取值了。BeanUtils.populate的作用

相关文章:

  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2022-12-23
  • 2021-11-14
  • 2021-11-02
  • 2022-01-21
  • 2021-05-26
相关资源
相似解决方案