Commons BeanUtils 中对Map的操作
<h1>
<span class="link_title"><a href="/linminqin/article/details/6697303">
Commons BeanUtils 中对Map的操作
</a></span>
</h1>
<div class="article_manage clearfix">
<div class="article_l">
<span class="link_categories">
标签:
<a href="http://www.csdn.net/tag/bean" target="_blank" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">bean</a><a href="http://www.csdn.net/tag/integer" target="_blank" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_tag']);">integer</a>
</span>
</div>
<div class="article_r">
<span class="link_postdate">2011-08-18 10:32</span>
<span class="link_view" title="阅读次数">3966人阅读</span>
<span class="link_comments" title="评论次数"> <a href="#comments" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_pinglun'])">评论</a>(0)</span>
<span class="link_collect tracking-ad" data-mod="popu_171"> <a href="javascript:void(0);" onclick="javascript:collectArticle('Commons+BeanUtils+%e4%b8%ad%e5%af%b9Map%e7%9a%84%e6%93%8d%e4%bd%9c','6697303');return false;" title="收藏" target="_blank">收藏</a></span>
<span class="link_report"> <a href="#report" onclick="javascript:report(6697303,2);return false;" title="举报">举报</a></span>
</div>
</div>
<div class="embody" style="display:none" id="embody">
<span class="embody_t">本文章已收录于:</span>
<div class="embody_c" id="lib" value="{"err":0,"msg":"ok","data":[]}"></div>
</div>
<style type="text/css">
.embody{
padding:10px 10px 10px;
margin:0 -20px;
border-bottom:solid 1px #ededed;
}
.embody_b{
margin:0 ;
padding:10px 0;
}
.embody .embody_t,.embody .embody_c{
display: inline-block;
margin-right:10px;
}
.embody_t{
font-size: 12px;
color:#999;
}
.embody_c{
font-size: 12px;
}
.embody_c img,.embody_c em{
display: inline-block;
vertical-align: middle;
}
.embody_c img{
width:30px;
height:30px;
}
.embody_c em{
margin: 0 20px 0 10px;
color:#333;
font-style: normal;
}
</style>
<script type="text/javascript">
$(function () {
try
{
var lib = eval("("+$("#lib").attr("value")+")");
var html = "";
if (lib.err == 0) {
$.each(lib.data, function (i) {
var obj = lib.data[i];
//html += '<img src="' + obj.logo + '"/>' + obj.name + " ";
html += ' <a href="' + obj.url + '" target="_blank">';
html += ' <img src="' + obj.logo + '">';
html += ' <em><b>' + obj.name + '</b></em>';
html += ' </a>';
});
if (html != "") {
setTimeout(function () {
$("#lib").html(html);
$("#embody").show();
}, 100);
}
}
} catch (err)
{ }
});
</script>
<div class="category clearfix">
<div class="category_l">
<img src="http://static.blog.csdn.net/images/category_icon.jpg">
<span>分类:</span>
</div>
<div class="category_r">
<label onclick="GetCategoryArticles('1414064','linminqin','top','6697303');">
<span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_fenlei']);">Apache工具<em>(2)</em></span>
<img class="arrow-down" src="http://static.blog.csdn.net/images/arrow_triangle _down.jpg" style="display:inline;">
<img class="arrow-up" src="http://static.blog.csdn.net/images/arrow_triangle_up.jpg" style="display:none;">
<div class="subItem">
<div class="subItem_t"><a href="http://blog.csdn.net/linminqin/article/category/1414064" target="_blank">作者同类文章</a><i class="J_close">X</i></div>
<ul class="subItem_l" id="top_1414064">
</ul>
</div>
</label>
</div>
</div>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/category.js"></script>
<div class="bog_copyright">
<p class="copyright_p">版权声明:本文为博主原创文章,未经博主允许不得转载。</p>
</div>
populate(bean,map) 将Map中的值设入bean中
- BeanUtils.populate(bean, request.getParameterMap());

BeanUtils.populate(bean, request.getParameterMap());
PropertyUtils.describe() 方法将返回bean中每个可读的属性都添加到Map中去.如果值为设置,将返回默认值,在上面的例子中假如Book类中还有个Integer型的page属性,代表书籍页数.在没设置的情况下,将返回null.如果page属性为int型,则将返回0
摘自:http://www.blogjava.NET/hexuzhong/archive/2005/11/30/21925.html
- Person author = new Person();
- author.setName("Timothy M. O'Brien");
- Book book = new Book();
- book.setName("Jakarta Commons Cookbook");
- book.setAuthor(author);
- // 取得book中的所有可读属性,返回到map中
- Map bookMap = PropertyUtils.describe(book);
- // Book类中包含一个Author类型的属性
- // 取bookMap中的author bean,并将其所有可读属性返回到authorMap中
- Map authorMap = PropertyUtils.describe(bookMap.get("author"));
- // 输出
- // Book Name: Jakarta Commons Cookbook
- // Author Name: Timothy M. O'Brien
- System.out.println("Book Name: " + bookMap.get("name"));
- System.out.println("Author Name: " + authorMap.get("name"));

Person author = new Person();
author.setName("Timothy M. O'Brien");Book book = new Book();
book.setName("Jakarta Commons Cookbook");
book.setAuthor(author); // 取得book中的所有可读属性,返回到map中
Map bookMap = PropertyUtils.describe(book);
// Book类中包含一个Author类型的属性
// 取bookMap中的author bean,并将其所有可读属性返回到authorMap中
Map authorMap = PropertyUtils.describe(bookMap.get("author")); // 输出
// Book Name: Jakarta Commons Cookbook
// Author Name: Timothy M. O'Brien
System.out.println("Book Name: " + bookMap.get("name"));
System.out.println("Author Name: " + authorMap.get("name"));</pre><br>
<div id="digg" articleid="6697303">
<dl id="btnDigg" class="digg digg_disable" onclick="btndigga();">
<dt>顶</dt>
<dd>1</dd>
</dl>
<dl id="btnBury" class="digg digg_disable" onclick="btnburya();">
<dt>踩</dt>
<dd>0</dd>
</dl>
</div>
<div class="tracking-ad" data-mod="popu_222"><a href="javascript:void(0);" target="_blank"> </a> </div>
<div class="tracking-ad" data-mod="popu_223"> <a href="javascript:void(0);" target="_blank"> </a></div>
<script type="text/javascript">
function btndigga() {
$(".tracking-ad[data-mod='popu_222'] a").click();
}
function btnburya() {
$(".tracking-ad[data-mod='popu_223'] a").click();
}
</script>
<div style="clear:both; height:10px;"></div>
<div class="similar_article" style="">
<h4>我的同类文章</h4>
<div class="similar_c" style="margin:20px 0px 0px 0px">
<div class="similar_c_t">
<label class="similar_cur">
<span style="cursor:pointer" onclick="GetCategoryArticles('1414064','linminqin','foot','6697303');">Apache工具<em>(2)</em></span>
</label>
</div>
<div class="similar_wrap tracking-ad" data-mod="popu_141" style="max-height:195px;">
<a href="http://blog.csdn.net" style="display:none" target="_blank">http://blog.csdn.net</a>
<ul class="similar_list fl"><li><em>•</em><a href="http://blog.csdn.net/linminqin/article/details/18798781" id="foot_aritcle_18798781undefined74989474812581" target="_blank" title="org.apache.commons.beanutils.ConversionException: No value specified for 'Date'">org.apache.commons.beanutils.ConversionException: No value specified for 'Date'</a><span>2014-01-26</span><label><i>阅读</i><b>10677</b></label></li> </ul>
<ul class="similar_list fr"><li><em>•</em><a href="http://blog.csdn.net/linminqin/article/details/7929863" id="foot_aritcle_7929863undefined2344384397348549" target="_blank" title="BeanUtils.copyProperties 如果Integer 或Long 为null 默认赋值0">BeanUtils.copyProperties 如果Integer 或Long 为null 默认赋值0</a><span>2012-08-31</span><label><i>阅读</i><b>3995</b></label></li> </ul>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
GetCategoryArticles('1414064', 'linminqin','foot','6697303');
});
</script>
<div>
<div class="J_adv" data-view="true" data-mod="ad_popu_205" data-mtp="43" data-order="114" data-con="ad_content_1900" style="width: 728px; height: 90px;"><script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-8990951720398508" data-ad-slot="8267689356/3776917242" data-adsbygoogle-status="done"><ins id="aswift_0_expand" style="display:inline-table;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent"><ins id="aswift_0_anchor" style="display:block;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent"><iframe width="728" height="90" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&&s.handlers,h=H&&H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&&d&&(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;"></iframe></ins></ins></ins><script>(adsbygoogle=window.adsbygoogle || []).push({});</script></div>
</div>
.blog-ass-articl dd {
color: #369;
width: 99%; /*修改行*/
float: left;
overflow: hidden;
font: normal normal 12px/23px "SimSun";
height: 23px;
margin: 0;
padding: 0 0 0 10px;
margin-right: 30px;
background: url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;
}
参考知识库

-
.NET知识库
2911关注|815收录
<dt><span>猜你在找</span></dt>
<div id="adCollege" style="width: 42%;float: left;">
<script src="http://csdnimg.cn/jobreco/job_reco.js" type="text/javascript"></script>
<script type="text/javascript">
csdn.position.showEdu({
sourceType: "blog",
searchType: "detail",
searchKey: "6697303",
username: "",
recordcount: "5",
containerId: "adCollege" //容器DIV的id。
});
</script>
<div class="tracking-ad" data-mod="popu_84"><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/1176" title="Python编程基础视频教程(第三季)" strategy="v4:hot" target="_blank">Python编程基础视频教程(第三季)</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/1182" title="Python编程基础视频教程(第六季)" strategy="v4:hot" target="_blank">Python编程基础视频教程(第六季)</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/299" title="从此不求人:自主研发一套PHP前端开发框架" strategy="v4:hot" target="_blank">从此不求人:自主研发一套PHP前端开发框架</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/1153" title="Swift视频教程(第五季)" strategy="v4:hot" target="_blank">Swift视频教程(第五季)</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/925" title="Swift视频教程" strategy="v4:hot" target="_blank">Swift视频教程</a></dd></div></div>
<div id="res" data-mod="popu_36" class="tracking-ad" style="width: 42%; float: left; margin-right: 30px; display: block;"><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/u010087830/article/details/12647883" title="面试总结" strategy="SearchAlgorithm" target="_blank">面试总结</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/hepanlaurence/article/details/51479430" title="webmagic采集CSDN的Java_WebDevelop页面" strategy="SearchAlgorithm" target="_blank">webmagic采集CSDN的Java_WebDevelop页面</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/u014403008/article/details/44623779" title="JAVA面试总结" strategy="SearchAlgorithm" target="_blank">JAVA面试总结</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/permike/article/details/44906463" title="java相关问题" strategy="SearchAlgorithm" target="_blank">java相关问题</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/languobeibei/article/details/53542038" title="android网络编程" strategy="SearchAlgorithm" target="_blank">android网络编程</a></dd></div>
<div id="ad_cen">
<!-- 广告位开始 -->
<div class="J_adv" data-view="true" data-mod="ad_popu_72" data-mtp="61" data-order="114" data-con="ad_content_1937"><script id="popuLayer_js_q" src="http://ads.csdn.net/js/popuLayer.js" defer="" type="text/javascript"></script><div id="location_parent_google"></div><script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><div id="layerd_google" style="position: fixed; bottom: 0px; right: 0px; line-height: 0px; z-index: 1000; width: 302px; height: 275px; display: none;"><div class="J_close layer_close" style="display:;background-color:#efefef;padding:0px;color:#333;font:12px/24px Helvetica,Tahoma,Arial,sans-serif;text-align:right;">关闭</div><ins class="adsbygoogle" style="display: inline-block; width: 300px; height: 250px;" data-ad-client="ca-pub-8990951720398508" data-ad-slot="8267689356/2658895482" data-adsbygoogle-status="done"><ins id="aswift_2_expand" style="display:inline-table;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent"><ins id="aswift_2_anchor" style="display:block;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent"><iframe width="300" height="250" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&&s.handlers,h=H&&H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&&d&&(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_2" name="aswift_2" style="left:0;position:absolute;top:0;"></iframe></ins></ins></ins></div><script>(adsbygoogle=window.adsbygoogle || []).push({});</script><script> document.getElementById('popuLayer_js_q').onload=function(){ var styObjd=styObj={width:'302px',height:'275px'};window.CSDN.Layer.PopuLayer('#layerd_google',{storageName:'layerd',styleObj:styObjd,total:50,expoire:1000*60}); }</script></div>
<!-- 广告位结束 -->
<div id="ad_bot">
</div>
<a id="quick-reply" class="btn btn-top q-reply" title="快速回复" style="display:none;">
<img src="http://static.blog.csdn.net/images/blog-icon-reply.png" alt="快速回复">
</a>
<a id="d-top-a" class="btn btn-top backtop" style="display: none;" title="返回顶部" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_huidaodingbu'])">
<img src="http://static.blog.csdn.net/images/top.png" alt="TOP">
</a>
.tag_list
{
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #D7CBC1;
color: #000000;
font-size: 12px;
line-height: 20px;
list-style: none outside none;
margin: 10px 2% 0 1%;
padding: 1px;
}
.tag_list h5
{
background: none repeat scroll 0 0 #E0DBD3;
color: #47381C;
font-size: 12px;
height: 24px;
line-height: 24px;
padding: 0 5px;
margin: 0;
}
.tag_list h5 a
{
color: #47381C;
}
.classify
{
margin: 10px 0;
padding: 4px 12px 8px;
}
.classify a
{
margin-right: 20px;
white-space: nowrap;
}
<h5>
<a href="http://www.csdn.net/tag/" target="_blank">核心技术类目</a></h5>
<div class="classify">
全部主题
Hadoop
AWS
移动游戏
Java
Android
iOS
Swift
智能硬件
Docker
OpenStack
VPN
Spark
ERP
IE10
Eclipse
CRM
JavaScript
数据库
Ubuntu
NFC
WAP
jQuery
BI
HTML5
Spring
Apache
.NET
API
HTML
SDK
IIS
Fedora
XML
LBS
Unity
Splashtop
UML
components
Windows Mobile
Rails
QEMU
KDE
Cassandra
CloudStack
FTC
coremail
OPhone
CouchBase
云计算
iOS6
Rackspace
Web App
SpringSide
Maemo
Compuware
大数据
aptech
Perl
Tornado
Ruby
Hibernate
ThinkPHP
HBase
Pure
Solr
Angular
Cloud Foundry
Redis
Scala
Django
Bootstrap
Commons BeanUtils 中对Map的操作的更多相关文章
- Guava中这些Map的骚操作,让我的代码量减少了50%
原创:微信公众号 码农参上,欢迎分享,转载请保留出处. Guava是google公司开发的一款Java类库扩展工具包,内含了丰富的API,涵盖了集合.缓存.并发.I/O等多个方面.使用这些API一方面 ...
- org.apache.commons.beanutils.BeanMap简单使用例子
一.org.apache.commons.beanutils.BeanMap; 将一个java bean允许通过map的api进行调用, 几个支持的操作接口: Object get(Object ke ...
- Apache Commons Beanutils 三 (BeanUtils、ConvertUtils、CollectionUtils...)
前言 前面已经学习了Apache Commons Beanutils包里的PropertyUtils和动态bean,接下来将学习剩下的几个工具类,个人觉得还是非常实用的,特别是CollectionUt ...
- 对于Java Bean的类型转换问题()使用 org.apache.commons.beanutils.ConvertUtils)
在进行与数据库的交互过程中,由数据库查询到的数据放在 map 中,由 map 到 JavaBean 的过程中可以使用 BeanUtils.populate(map,bean)来进行转换 这里要处理的问 ...
- Apache Commons Beanutils 二 (动态Bean - DynaBeans)
相关背景 上一篇介绍了PropertyUtils的用法,PropertyUtils主要是在不修改bean结构的前提下,动态访问bean的属性: 但是有时候,我们会经常希望能够在不定义一个Java类的前 ...
- org.apache.commons.beanutils.BeanUtils的常见用法
import org.apache.commons.beanutils.BeanUtils BeanUtils1. public static void copyProperty(Object bea ...
- 将List集合中的map对象转为List<对象>形式--封装类
import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Li ...
- 再续前缘-apache.commons.beanutils的补充
title: 再续前缘-apache.commons.beanutils的补充 toc: true date: 2016-05-32 02:29:32 categories: 实在技巧 tags: 插 ...
- POI中HSSF和XSSF操作Excel
POI中HSSF和XSSF操作Excel 在公司实习快一个月了,这段时间公司业务要用JAVA操作复杂的Excel报表.刚开始的Excel还好,没有涉及到复杂的图表,所以使用JXL操作Excel,但 ...
随机推荐
- Hibernate学习(七)
Hibernate缓存 1.一级缓存:Session 级别的缓存 2.二级缓存: SessionFactory 级别的缓存 3.查询缓存:需二级缓存的支持,查询缓存依赖二级缓存 一级缓存 1.依赖于 ...
- MySQL复制方法
MySQL的二进制日志,MySQL复制原理,MySQL主从模式搭建,MySQL双主模式搭建,MySQL级联模式搭建,MySQL半同步模式复制 一.二进制日志 1.概念 MySQL的二进制日志(bina ...
- 【Fine学习笔记】python 文件l操作方法整理
python脚本可以对excel进行创建.读.写.保存成指定文件名,保存到指定路径的操作.整理了以下处理方法: 首先区别几个操作方式: "r" 以读方式打开,只能读文件 , 如 ...
- [运维] 请求 nginx 出现 502 Bad Gateway 的解决方案!
环境: 云服务器镜像 Linux CentOS 7.6 已经安装并成功配置 SSL 的 nginx 1.16.1 成功安装并且可以正常运行的 apache-tomcat-9.0.26 遇到的问题: 在 ...
- 笔记-AJAX
笔记-AJAX 1. 简介 Ajax 即“Asynchronous Javascript And XML”(异步 JavaScript 和 XML AJAX 是一种用于创建快速动态网页的技术 ...
- Spring SpringMVC 和 Springboot 的关系(转载)
原文链接 spring boot就是一个大框架里面包含了许许多多的东西,其中spring就是最核心的内容之一,当然就包含spring mvc. spring mvc 是只是spring 处理web层请 ...
- leetcode刷题-- 2. 排序(待更新)
排序 参考五分钟学算法 复杂度比较 时间复杂度 O(n2) 各种简单的排序:直接插入.直接选择.冒泡 O(nlog2n) 快速排序.堆排序.归并排序 O(n1+\(\lambda\)),希尔排序 线性 ...
- .net core 2.1控制台使用Quartz.net实现定时任务执行
权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/qq_33435149/article/de ...
- Python函数-2 匿名函数
匿名函数 当我们在创建函数时,有些时候,不需要显式地定义函数,直接传入匿名函数更方便.这省去了我们挖空心思为函数命名的麻烦,也能少写不少代码,很多编程语言都提供这一特性. Python语言使用lamb ...
- 关于Android file.createNewFile() 方法出现的问题总结(转)
原文:http://blog.csdn.net/wjdarwin/article/details/7108606 今天在编写向SDcard中,创建文件夹并向其中保存文件的过程中出现个一系列的问题 在此 ...