﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-waysun一路阳光</title><link>http://www.blogjava.net/1504/</link><description>不轻易服输,不轻言放弃.--心是梦的舞台，心有多大，舞台有多大。踏踏实实做事，认认真真做人。</description><language>zh-cn</language><lastBuildDate>Mon, 04 May 2026 06:51:49 GMT</lastBuildDate><pubDate>Mon, 04 May 2026 06:51:49 GMT</pubDate><ttl>60</ttl><item><title>产品经理必备6大素质：没有＂强迫症＂的PM不是好PM</title><link>http://www.blogjava.net/1504/archive/2014/09/24/418213.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Wed, 24 Sep 2014 02:12:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2014/09/24/418213.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/418213.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2014/09/24/418213.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/418213.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/418213.html</trackback:ping><description><![CDATA[转自：http://www.yixieshi.com/it/16032.html<br /><div txt-shadow"="" style="text-shadow: #ffffff 0px 1px 0px; height: 24px; background-color: #f3f3f3; color: #999999; font-size: 12px; text-align: center; line-height: 24px; font-family: Arial, Helvetica, Arial, sans-serif;"><p style="margin: 0px 0px 10px;"><span style="margin: 5px;">时间：2014-02-12 21:42</span>&nbsp;<span style="margin: 5px;">来源：<a href="http://www.geekpark.net/read/view/197918" target="_blank" style="color: #999999; text-decoration: none;">极客公园</a></span>&nbsp;<span style="margin: 5px;">作者：功夫小猫</span></p></div><div style="margin-top: 15px; color: #454545; font-family: Arial, Helvetica, Arial, sans-serif; line-height: 20px; background-color: #ffffff;"><center><img alt="产品经理必备6大素质：没有＂强迫症＂的PM不是好PM,互联网的一些事" height="310" src="http://www.yixieshi.com/uploads/allimg/140212/21395JM7-0.jpg" width="650" original="http://www.yixieshi.com/uploads/allimg/140212/21395JM7-0.jpg" style="height: auto; max-width: 680px; vertical-align: middle; border: 0px; background-image: none; background-attachment: scroll; margin: 15px auto; background-position: 0px 0px; background-repeat: repeat repeat;" /></center><p style="margin: 0px 0px 10px; line-height: 28px;">　　[核心提示] 你觉得自己是个好的产品经理吗?或者，你还想做产品经理吗?你得具备以下的6大要素么?</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　很多人都在向往产品经理这个角色，甚至是设计师、程序员、BD，都有做产品经理的想法。我这么多年一直是做技术，虽然头衔都是技术相关的，但基本都是从产品角度去思考技术实施。正好最近我们在考虑计划设计一个社交类产品，从我的角度，把我对产品经理这个职位的认识谈一谈。</p><p style="margin: 0px 0px 10px; line-height: 28px;"><span style="color: #b22222;"><span style="font-size: 16px;">　　<strong>对于很多小公司来说，&#8220;产品经理&#8221;不过是个摆设</strong></span></span></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我对&#8220;出色的产品&#8221;这么理解：</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　1、对产品本身，有很好的市场定位、用户，以及前景;</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　2、对产品的用户使用，有很高的用户认可度;</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　3、对产品的市场投放，有高明的手段;</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我先讲一个故事。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　一个朋友，是产品经理，几个月以前，他们公司开发了一款产品，在青岛试点推广，当时和我谈论这个产品的定义以及市场、用户以及推广，感觉他态度是很乐观的，给我的直接信号就是这应该是一个&#8220;出色的产品&#8221;。而在随后的一个月，他给我打电话，态度很悲观，说这个产品市场反应效果不好，又两个月之后，他去了北京，再给我打电话谈论到这个这个产品，说已经进入融资状态，感觉他又非常乐观，本来我以为他的产品进行了什么大改进，结果聊完才知道，产品没任何改进，只是他们的股东当中有融资的渠道。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　通过他对这个产品的态度转变，可以肯定，他并没有权利对这个产品进行把控。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　首先，产品在青岛市场反馈不好，那么作为产品经理有完全的责任，这是一点不能推卸的。产品经理需要对产品做出前瞻性的市场判断，市场失利，很可能产品的定位出现问题，或者是没有把握准确的推出时机。出了问题之后应该第一时间纠正产品定位而不是去融资。实际上我了解到，他们的产品定位完全是老板决定的，市场推出时机和策略也是老板决定的。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　国内一些小企业，一个普遍的现象，就是责任不清晰，某个环节失败后不深刻认识、吸取教训，而是推卸责任给其他部门和其他人，慢慢就不了了之了。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　其次，能有融资的渠道，只能说公司有了潜在的资金来源，这和产品本身没任何关系，产品定位没变、产品本身设计没变，产品一直实实在在的摆在那里，怎么可能有了融资渠道就意味着产品有了希望，这简直就像一群人在起哄一样。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我们聊天中，他也透露了，产品完全由他老板一个人说的算。也就是说产品经理这个职位不过是个摆设。</p><p style="margin: 0px 0px 10px; line-height: 28px;"><span style="color: #b22222;"><span style="font-size: 16px;">　　<strong>产品经理的角色</strong></span></span></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　产品经理的角色很复杂，一方面每个公司对产品经理这个职位的定义是不同的，再有一方面也是最根本的原因，就是产品经理这个职位需要跨多个领域，一般来说，产品都涉及：</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　产品的出现 &#8212;&#8212; 业务部分;</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　用户直接接触的 &#8212;&#8212; 用户体验部分;</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　产品的开发实施 &#8212;&#8212; 技术部分;</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　产品经理不一定是这三个领域的专家，但至少要熟知这三个领域，不然很难驾驭一个出色的产品。打造一款出色的产品并不是容易的事情，这需要产品经理有很好市场判断以及控制力和追求完美的品质。</p><center><img alt="产品经理必备6大素质：没有＂强迫症＂的PM不是好PM,互联网的一些事" height="387" src="http://www.yixieshi.com/uploads/allimg/140212/21395M555-1.png?imageView/2/w/620/q/100" width="520" original="http://www.yixieshi.com/uploads/allimg/140212/21395M555-1.png?imageView/2/w/620/q/100" style="height: auto; max-width: 680px; vertical-align: middle; border: 0px; background-image: none; background-attachment: scroll; margin: 15px auto; display: inline; background-position: 0px 0px; background-repeat: repeat repeat;" /></center><p style="margin: 0px 0px 10px; line-height: 28px;"><span style="color: #b22222;"><span style="font-size: 16px;">　　<strong>&#8220;产品经理&#8221;是&#8220;总经理&#8221;的摇篮</strong></span></span></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我的意思是说，产品经理需要很综合的素质，基本上涵盖了整个公司部门，实际上产品经理是&#8221;操心的命&#8220;：</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　懂行业、懂这个行业的用户(甚至需要是这个行业的专家)。任何产品都不是凭空想出来的，都深深依托在他所在行业的发展背景中，你对这个领域认知程度，以及前瞻性，都决定了你的产品的命运。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　有控制力，控制团队协作，以及与其他部门的沟通。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　在有限的时间和资源前提下做产品和市场的权衡(在日企工作的朋友，都听过一个词叫&#8220;担当&#8221;)。不能推卸责任给其他部门，不要依赖其他环节的成功(这是我见过最多的现象，一旦市场投放失败，公司内部各部门无限循环推卸责任，产品经理把责任推卸给技术和设计，是最常见的)</p><p style="margin: 0px 0px 10px; line-height: 28px;"><strong><span style="font-size: 16px;"><span style="color: #b22222;">　　具体来说，产品经理需要具备以下特质：</span></span></strong></p><p style="margin: 0px 0px 10px; line-height: 28px;">　<strong>　第一、产品经理要有很高的洞察力和预见性，不仅仅是一个Idea</strong></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我觉得只要是头脑正常的人，都会有各种想法和观点，这并不能说明他有多聪明和头脑灵活，退一步讲，就算这个人的想法被其他人接受，也未必说明这个想法具有市场价值，未必能从想法衍生出好的产品，因为每个人的见识、阅历有限，把想法投放给小部分人得到认可不能说明太多问题。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　乔布斯的伟大，很大程度上是他的预见性，能准确的判断出 PC 未来 10 年的发展，能准确预见互联网的未来，这是产品能成功的关键。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　比如对移动互联网的预测，2014 年必定是移动移动互联网爆发的一年，移动支付领域、O2O 领域、移动办公领域都会有飞速发展。移动互联网发展迅猛到让人乍舌，一年多前，一些非 IT 人士，不会弄 Android 手机还是很正常现象，现在街上的出租车司机如果不会用打车软件、不会用移动支付，已经被同行嘲笑了。如果产品经理不能预测出未来市场变化，就会错失良机，要么被同行弄死，要么被用户抛弃。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　<strong>第二、产品经理要懂用户，甚至要置身于客服的位置</strong></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我这里再讲一个故事，这个故事我也讲了很多次。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我曾经带领团队开发一个商城平台，他们的用户是大街上维修手机的店铺，后期我们计划为商家提供更多服务，我就设想能否为每个维修店设计一个专门页面，通过 SEO 优化，为他们通过网上带来修手机客户。结果我们事先在他们的论坛上做了一个调查，其中有一个客户的反馈触动了我，他说&#8221;会使用互联网搜索的人，不会来修手机&#8220;，我就立即意识到我对这些维修店了解不够，实际上他们面对的客户群体往往是民工居多。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我曾经见过做车载导航统计的公司，他们在做产品的时候，要和司机师傅一同作息，就是为了跟进产品，甚至要夜间出去。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　在这方面，我觉得产品经理的工作是非常辛苦的，相反那些实实在在存在的产品经理，不屑底层工作、总有高高在上优越感，每天都办公室梦想设计出伟大产品，觉得运筹帷幄中决胜千里外，控制欲是他想成为产品经理的唯一理由，这样的产品经理是没有机会做出好的产品的。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　<strong>第三、没错，按钮的定义不是设计师决定的，这是产品经理的职责</strong></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　国内那些专门打造用户体验的团队，一般都称为 UED，最早见于阿里巴巴，在国外公司一般都成为 UX，设计团队与产品的用户体验接触最密切，UI 和 UE 这些范畴以及他们工作中的一些专业方法，产品经理都要懂，不然是没有办法把用户需要转换成设计交互语言的。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　如果你不给设计师设定一个场景，那么设计师有一百个理由做出一百个按钮的设计，从设计角度说，这些设计都是合格的。产品经理就是这个设计场景的人，就电影《Inception》中，梦境设计者(Architect)会给造梦者设定梦境，造梦者依据设计造梦，否则，造梦者真的可以随意做美梦了。</p><center><img alt="产品经理必备6大素质：没有＂强迫症＂的PM不是好PM,互联网的一些事" height="374" src="http://www.yixieshi.com/uploads/allimg/140212/21395I103-2.jpg?imageView/2/w/620/q/100" width="500" original="http://www.yixieshi.com/uploads/allimg/140212/21395I103-2.jpg?imageView/2/w/620/q/100" style="height: auto; max-width: 680px; vertical-align: middle; border: 0px; background-image: none; background-attachment: scroll; margin: 15px auto; display: inline; background-position: 0px 0px; background-repeat: repeat repeat;" /></center><p style="margin: 0px 0px 10px; line-height: 28px;">　　如果是一个互联网产品，一个按钮、背景颜色，实际上都是取决于产品使用者的特定的背景的，他的地域背景、互联网文化背景等等，而这些不是设计师职责范围的。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我们在两年前做了一个东南亚移动互联网的平台，当时的设计师是我的朋友，因为这是个 Startup，所以人手有限，我的朋友在做设计的同时，也是做了一部分产品经理的角色的，比如东南亚地区更喜欢色彩靓丽的风格，那么整套产品都会体现这一特点。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　所以，如果用户觉得产品外观丑的要命，不要再把责任推卸给设计师。</p><p style="margin: 0px 0px 10px; line-height: 28px;"><strong>　　第四、产品经理把业务实体抽象成模型转换到产品方案上是最困难的</strong></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　我觉得这一个环节是最难把控的。一般来说，每个公司可能都有自己的一套方法论，更多都是根据产品的性质和公司的习惯来制定的，很难整理出来通用的方法。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　比如你要设计一款 iPad 售楼展示系统给售楼处来使用，你可能要兼顾双重使用者，售楼员以及购房者，购房者更关注位置、实际样板间图片展示、价格、交通、优惠，而售楼员更在意便捷性，直接在 iPad 上记录了购房者信息、购房者对这个楼盘的满意程度，是否有必要在一段时间后电话回访。那么综合这些指标，考虑产品的设计要优先体现出来哪部分在显要位置。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　<strong>　第五、产品经理要在团队中打造个人魅力</strong></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　你既然不是那三个领域的专家，那人家为什么要信服你?这可能就需要你有个人魅力(如果你本身够帅气到也是个优势)，要凭借你的实力打造在团队中的影响，就像小说中的张无忌，如果不会九阳神功和乾坤大挪移，是很难服众的，也别指望身边有 4 个女人追随了。</p><p style="margin: 0px 0px 10px; line-height: 28px;"><strong>　　第六、产品经理需要有很强的控制欲，某种程度上说，那些&#8220;强迫症&#8221;、&#8220;偏执狂&#8221;更适合做产品经理</strong></p><p style="margin: 0px 0px 10px; line-height: 28px;">　　如果你为了保住在公司的地位，不敢和你的上级顶嘴，不敢和其他部门说&#8220;NO&#8221;，不敢为了一个像素和同事争得面红耳赤，是很难打造出色的产品的。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　这方面，乔布斯像外界说的那样偏执，我到很认同他的做法，就像《The lost interview》中对他的采访中他说的：伟大的人，不会在意自尊，大家都是把注意力集中到产品上，这毕竟是最有效的工作方式。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　同样，在某些企业里，说话要小心、发邮件要注意措辞，不能得罪人、搞明哲保身这一套，在这样的公司，也只能老老实实混点工资了。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　实际上，对于产品的把控，我更愿意由工程师来决定，Facebook 是典型的工程师驱动产品，这样好处是因为，避免了很多交接环节(如果通过产品经理把用户反馈传递给工程师，中间会损失很多信息)，再有一个就是，毕竟产品的存在和技术太紧密了。如果要工程师驱动你的产品，就需要工程师具备产品经理的素质。</p><p style="margin: 0px 0px 10px; line-height: 28px;">　　看完这些，你觉得自己是个好的产品经理吗?或者，你还想做产品经理吗?</p></div><img src ="http://www.blogjava.net/1504/aggbug/418213.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2014-09-24 10:12 <a href="http://www.blogjava.net/1504/archive/2014/09/24/418213.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mybatis set session time zone【转-总结】</title><link>http://www.blogjava.net/1504/archive/2014/04/30/413075.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Wed, 30 Apr 2014 02:11:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2014/04/30/413075.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/413075.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2014/04/30/413075.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/413075.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/413075.html</trackback:ping><description><![CDATA[<div>转自：http://blog.csdn.net/zhy0511/article/details/8262634<br /><br /><span style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;">最近在写一个项目，持久层想用mybatis，但是查询的时候如果有TimeStamp的数据则会抛出</span><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;"></p><pre style="white-space: pre-wrap; word-wrap: break-word; font-size: 14.44444465637207px; background-color: #ffffff; color: #222222; line-height: 19px;">java.sql.SQLException: Session Time Zone not set!</pre><span style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;">的异常，经过网上的查找，发现是由于oracle数据库中在建表的时候TimeStamp类型的字段加上了&nbsp;WITH LOCAL TIME ZONE的条件，所以在取日期类型的值时需要设置Time Zone. 但是找了很久都没有发现mybatis的配置中有关于Session Time Zone的配置。最终发现sessionTimeZone的设置在oracle.jdbc.OracleConnection中。于是考虑到可以将connection向下转型成oracle.jdbc.OracleConnection。经过搜索发现可以通过</span><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;"></p><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;"></p><div bg_java"="" style="width: 700.9027709960938px; color: #333333; line-height: 26px;"><div><div><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/zhy0511/article/details/8262634#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/zhy0511/article/details/8262634#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 636px; top: 610px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1"><li style="line-height: 20px;">SqlSessionFactory.getConfiguration().getEnvironment()&nbsp;&nbsp;</li><li style="line-height: 20px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.getDataSource().getConnection();&nbsp;&nbsp;</li></ol></div><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;">中可以拿到connection，但是最终却发现这个connection对象是个代理对象，强制转换成oracle.jdbc.OracleConnection时就会抛出类型转换的异常。如此将问题解决的对象转移到如何拿到oracle.jdbc.OracleConnection对象，最终在网上找到一篇相关文章，可以使用org.apache.ibatis.datasource.pooled.PooledDataSource的静态方法unwrapConnection(Connection conn)获得real connection 对象。如此即可强制转换成oracle.jdbc.OracleConnection之后再对sessionTimeZone进行设置。设置方式如下：</p><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;"></p><div bg_java"="" style="width: 700.9027709960938px; color: #333333; line-height: 26px;"><div><div><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/zhy0511/article/details/8262634#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/zhy0511/article/details/8262634#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 636px; top: 872px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1"><li style="line-height: 20px;">((OracleConnection)&nbsp;realConn).setSessionTimeZone(TimeZone&nbsp;&nbsp;</li><li style="line-height: 20px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.getDefault().getID())&nbsp;&nbsp;</li></ol></div><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;">但是很遗憾的是，这个静态方法在当前mybatis最新办3.1.1版本中还有问题存在，它返回的依然是个代理对象(详见：<a href="http://code.google.com/p/mybatis/issues/detail?id=591" style="color: #336699; text-decoration: none;">http://code.google.com/p/mybatis/issues/detail?id=591</a>)。所以也只能等以后版本的更新了。如果大家有更好的办法set session time zone的话，希望能跟我分享一下，谢谢！！</p><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;">注：在mybatis将这个bug修复前，应该可以通过connection.createStatement().getConnection()拿到real connection</p><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;"><br /></p><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;"><span style="color: #ff0000;">今天又发现一种方式，可以使用java.sql.Connection.unwrap(Class)方法拿到real connection. 不过如果驱动包使用的是classes12.jar是不行的，估计是classes12.jar出现的时候java.sql.Connection接口中没有unwrap方法。不过ojdbc6.jar这个驱动包是可用的，并且需要注意的是，setSessionTimeZone方法的调用需要在拿到mybatis的sqlSession之后再设置，在创建SqlSessionFactory之后设置是不起作用的。具体原因应该是只有在拿SqlSession的时候才会去跟数据库建立连接吧。而且由于配置连接池的缘故，所以每次都的手动设置，具体代码如下：</span></p><p style="color: #333333; font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;"></p><div bg_java"="" style="width: 700.9027709960938px; color: #333333; line-height: 26px;"><div><div><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/zhy0511/article/details/8262634#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/zhy0511/article/details/8262634#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 636px; top: 1330px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1"><li style="line-height: 20px;">session.getConnection().unwrap(OracleConnection.class).setSessionTimeZone(TimeZone.getDefault().getID()); &nbsp;我的解决方法是在查询时将<span style="font-family: Arial; font-size: 14.44444465637207px; line-height: 26px; background-color: #ffffff;">TimeStamp类型字段</span><br />进行字符串转换,to_char(t.BRH_TIMESTAMP,'yyyy-MM-dd HH24:MI:SS'),</li></ol></div></div><img src ="http://www.blogjava.net/1504/aggbug/413075.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2014-04-30 10:11 <a href="http://www.blogjava.net/1504/archive/2014/04/30/413075.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>百度空间DOS系列：DOS目录操作类命令，md命令，cd命令，rd命令，tree命令详解</title><link>http://www.blogjava.net/1504/archive/2011/11/29/365096.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Tue, 29 Nov 2011 02:33:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/11/29/365096.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/365096.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/11/29/365096.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/365096.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/365096.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #333333; font-family: tahoma, arial, 宋体, sans-serif; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-align: left; "><span class="Apple-style-span" style="font-family: 宋体; line-height: 22px; background-color: #f9fcfe; ">好久没有更新百度博客，最近玩DOS，突然想找个地方把自己学习的东西总结整理一下，基本的DOS命令，希望和大家共同交流，如有关于本人的任何问题，我们可以互相交流一下。</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-align: left; "><span class="Apple-style-span" style="font-family: 宋体; line-height: 22px; background-color: #f9fcfe; "><br /></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-align: right; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span class="Apple-style-span" style="font-family: 宋体; line-height: 22px; background-color: #f9fcfe; ">MD(Make Directory)</span></p><span class="Apple-style-span" style="font-family: 宋体; line-height: 22px; background-color: #f9fcfe; "><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-family: 宋体; ">功能：创建新的子目录　</span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-family: 宋体; ">类型：内部命令　</span>&nbsp;<span style="line-height: 22px; font-family: 宋体; ">　　</span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">格式：</span><span style="line-height: 22px; font-size: 10.5pt; ">md &lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">盘符:&gt;</span><span style="line-height: 22px; font-size: 10.5pt; ">&lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">路径名</span><span style="line-height: 22px; font-size: 10.5pt; ">&gt; &lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">子目录名&gt;</span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">实例：</span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-family: 宋体; ">在本地磁盘E下新建一个love文件夹，并在其下新建dos文件夹目录</span></div><div style="font-size: 14px; line-height: 22px; "><span style="font-family: 宋体; line-height: 22px; "><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/9d08221a682385991ad57610.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div><br style="line-height: 22px; " /></span></div><div style="font-size: 14px; line-height: 22px; ">CD(Change Directory)</div><div style="font-size: 14px; line-height: 22px; "><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-family: 宋体; ">功能：改变当前目录</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-family: 宋体; ">类型：内部命令　</span>&nbsp;<span style="line-height: 22px; font-family: 宋体; ">　　</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">格式：cd</span><span style="line-height: 22px; font-size: 10.5pt; ">&nbsp;&lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">盘符:&gt;&nbsp;</span><span style="line-height: 22px; font-size: 10.5pt; ">&lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">路径名</span><span style="line-height: 22px; font-size: 10.5pt; ">&gt; &lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">子目录名&gt;</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-family: 宋体; ">实例：</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">根目录是驱动器的目录树状结构的顶层，要返回到根目录，在命令行输入：</span><span style="line-height: 22px; font-size: 10.5pt; ">cd \</span></span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-size: 10.5pt; "><span style="line-height: 22px; font-size: 10.5pt; "><div style="font-size: 14px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/44d48d1fb5cc90b8ac6e7510.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div><div style="font-size: 14px; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">如果想返回到上一层目录，在当前命令提示符下输入</span><span style="line-height: 22px; font-size: 10.5pt; ">cd..</span></div><div style="font-size: 14px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/3a8527f4297724ae7831aa1a.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">如果想进入下一层目录，在当前命令提示符下输入</span><span>cd&nbsp;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">目录名。在命令提示符</span><span>C:\&gt;documents and setting\cd adminstrator</span><span style="line-height: 22px; font-size: 10.5pt; "><br style="line-height: 22px; " /><div style="font-size: 14px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/ebd151f0a7ed2603dcc47410.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">如果想改变当前驱动器的目录</span><span>c:\documents and settings</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">，进入到</span><span style="line-height: 22px; font-size: 10.5pt; "><span>e</span></span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">驱动器默认目录，在当前命令行输入e</span><span>:&nbsp;</span><span style="line-height: 22px; font-size: 10.5pt; "><br style="line-height: 22px; " /><div style="font-size: 14px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/373e44d1105656a950da4b10.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">如果想在当前</span><span>C</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">驱动器上将</span><span style="line-height: 22px; font-size: 10.5pt; "><span>E</span></span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">驱动器上的默认目录更改为E</span><span>:\gqdp</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">，在命令行输入</span><span>cd /d e:\gdqp,同样可以直接进入其他驱动器目录</span></span></span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-size: 10.5pt; "><span style="line-height: 22px; font-size: 10.5pt; "><span><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/cefcf0c799708138b219a81a.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div>&nbsp;</span></span></span></div></span></span></div></div><div style="font-size: 14px; line-height: 22px; "><span style="font-family: 宋体; line-height: 22px; ">RD(Remove Directory)</span></div><div style="font-size: 14px; line-height: 22px; "><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-family: 宋体; ">功能：从指定的磁盘删除目录</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-family: 宋体; ">类型：内部命令　</span>&nbsp;<span style="line-height: 22px; font-family: 宋体; ">　　</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">格式：rd</span><span style="line-height: 22px; font-size: 10.5pt; ">&lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">盘符:&gt;&nbsp;</span><span style="line-height: 22px; font-size: 10.5pt; ">&lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">路径名</span><span style="line-height: 22px; font-size: 10.5pt; ">&gt; &lt;</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">子目录名&gt;</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; "><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/221ff26a63fcdab780cb4a10.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div><div style="font-size: 14px; line-height: 22px; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;q=quiet</div></span><span style="line-height: 22px; font-family: 宋体; ">实例：</span></div><div style="font-size: 14px; line-height: 22px; font-family: Arial, Helvetica, sans-serif; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; "><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">如果要删除e:</span><span style="line-height: 22px; font-size: 10.5pt; ">\abc</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">下的def</span><span style="line-height: 22px; font-size: 10.5pt; font-family: 宋体; ">文件夹（空或非空）。可以在命令提示符窗口下执行以下命令：</span><span style="line-height: 22px; font-size: 10.5pt; ">rd /s /q e:\abc\def</span></span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; "><span style="line-height: 22px; "><div style="font-size: 14px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/96092635eb143874eac4af1a.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div><div style="font-size: 14px; line-height: 22px; "><div style="font-size: 14px; line-height: 22px; "><span>如果我们所删除的目录文件夹下面还有其他内容（.doc .ppt .txt .bat .tmp...）我们必须加上/s，若不加如下图</span></div></div><span><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/94a482c0eee20aa638db4910.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div>如果我们再删除磁盘目录文件夹的时候不加/q，那么他们会提示我们Y或N来确认删除与否，如下图</span></span></span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; "><span style="line-height: 22px; "><span><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/e40e0ede41f3b2b6b7fd4810.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div>前面举的几个例子都是在磁盘c环境下删除其他磁盘的文件或目录，那么删除本盘的文件就更加简单了，在e盘根目录删除其下123所有目录及其子目录文件，不需要提示，直接删除 如下图</span></span></span></div></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; "><span style="line-height: 22px; "><div style="font-size: 14px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/6810decff8e33d9053664f10.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div></span></span></div></span><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; line-height: 22px; background-color: #ccced0; "><br /></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; line-height: 22px; background-color: #ccced0; ">Tree</span></p><span class="Apple-style-span" style="line-height: 22px; background-color: #ccced0; "><div style="font-size: 14px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; "><span style="line-height: 22px; font-family: 宋体; ">功能：显示指定驱动器上所有目录路径和这些目录下的所有文件名</span></div><div style="font-size: 14px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; "><span style="line-height: 22px; font-family: 宋体; "><span style="line-height: 22px; font-family: 宋体; ">类型：外部命令　</span><span style="line-height: 22px; color: black; ">&nbsp;</span></span><span style="line-height: 22px; font-family: 宋体; "><span style="line-height: 22px; font-family: 宋体; ">　　</span></span></div><div style="font-size: 14px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; "><span style="line-height: 22px; font-family: 宋体; "><span style="line-height: 22px; font-family: 宋体; ">格式：</span><span style="line-height: 22px; color: black; ">tree &lt;</span><span style="line-height: 22px; font-family: 宋体; ">盘符:&gt; &lt;</span></span><span style="line-height: 22px; font-family: 宋体; "><span style="line-height: 22px; color: black; ">/f&gt; &lt;/a&gt;</span><span style="line-height: 22px; font-family: 宋体; ">　</span></span></div><div style="font-size: 14px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; "><span style="line-height: 22px; font-family: 宋体; "><span style="line-height: 22px; font-family: 宋体; "><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/38236605450233637aec2c1d.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div></span></span><span>实例：</span></div><div style="font-size: 14px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; "><span style="line-height: 22px; "><span style="line-height: 22px; "><span><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/b47b9417ce12824edc5401e6.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div>如果目录下子目录比较多，子目录下文件又比较多的话，我们使用tree命令会发现一屏还没有看完就直接刷过去了，这里可以用more命令，具体为</span></span></span><span>tree /f | more，类似/p的作用，不过/p继续浏览是回车，但是</span><span>&nbsp;| more是空格 如下图</span></div><div style="font-size: 14px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; "><span><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/f2d9165081655639574e00e6.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div>和dir原理相似，tree同样可以输出&nbsp;E:\&gt;tree /f&gt;e:\123.txt&amp;start e:\123.txt</span></div><div style="font-size: 14px; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; "><span><div style="font-size: 14px; line-height: 22px; "><img alt="Dos command&#8212;目录操作类命令详解 - Anonymous - 轨 迹" src="http://hiphotos.baidu.com/%C9%DF%D0%CE%B5%F3/pic/item/00cb7e3bdd33f08155e7231d.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; line-height: 22px; border-style: initial; border-color: initial; max-width: 100%; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 0px; " /></div></span></div></span><span class="Apple-style-span" style="font-family: 宋体; line-height: 22px; background-color: #f9fcfe; "><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; "><span style="line-height: 22px; "><div style="font-size: 14px; "></div><div style="font-size: 14px; line-height: 22px; "><span style="font-family: 宋体; line-height: 22px; "></span></div><div style="font-size: 14px; line-height: 22px; "><span style="font-family: 宋体; line-height: 22px; "><div style="font-size: 14px; line-height: 22px; "></div></span></div><div style="font-size: 14px; line-height: 22px; "><span style="font-family: 宋体; line-height: 22px; "><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-family: Arial, Helvetica, sans-serif; "></span></div></span></div></span></span></div><div style="font-size: 14px; line-height: 22px; "><span></span></div><div style="font-size: 14px; line-height: 22px; "><span></span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-family: arial, 宋体, sans-serif; background-color: #f9fcfe; "><span style="line-height: 22px; font-family: 宋体; color: black; "></span></span></div><div style="font-size: 14px; line-height: 22px; "><span style="line-height: 22px; font-family: arial, 宋体, sans-serif; background-color: #f9fcfe; "><span style="line-height: 22px; font-family: 宋体; color: black; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p></span></span></div></span></span><img src ="http://www.blogjava.net/1504/aggbug/365096.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-11-29 10:33 <a href="http://www.blogjava.net/1504/archive/2011/11/29/365096.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat由于invalid LOC header (bad signature)不能启动【转】</title><link>http://www.blogjava.net/1504/archive/2011/11/17/364122.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Thu, 17 Nov 2011 10:34:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/11/17/364122.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/364122.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/11/17/364122.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/364122.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/364122.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #464646; font-family: simsun; ">原因是某个jar由于未知原因被破坏了，直接拷贝一个新的覆盖掉它即可。虽然字节完全一样。</span><img src ="http://www.blogjava.net/1504/aggbug/364122.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-11-17 18:34 <a href="http://www.blogjava.net/1504/archive/2011/11/17/364122.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CFCA 数字证书的安装与使用（转）</title><link>http://www.blogjava.net/1504/archive/2011/11/08/363204.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Tue, 08 Nov 2011 10:35:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/11/08/363204.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/363204.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/11/08/363204.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/363204.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/363204.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #5e5e5e; font-family: Verdana, Helvetica, Arial; font-size: 12px; line-height: 18px; "><div class="postcontent" style="font-size: 13px; "><div>CFCA 数字证书的安装与使用</div><div>前言</div><div>服务器证书（以下称WebServer 证书）是Web Server 与浏览器用户建立安全连接时所必须具备的证书。</div><div>WebServer 证书的密钥对由相应的Web Server 自己产生和管理，申请证书时只需将Web Server 产生的</div><div>证书申请数据包提交给CFCA 证书下载中心即可，密钥位长为512 位（或1024 位）。按照一定的步</div><div>骤CFCA 证书下载中心将返回证书应答，即可将证书装载到Web Server 中。目前，CFCA 能够签发</div><div>Netscape Web Server，Microsoft IIS server，Apache WebServer 等WWW 服务器的证书。</div><div>目录</div><div>第一章、WEB SERVER 证书的安装配置</div><div>1、在WEB SERVER 上产生证书请求</div><div>1.1 在Web Server 端产生密钥对</div><div>1.2 在Web Server 上产生证书申请</div><div>2、WEB SERVER 证书的下载</div><div>3、在WEB SERVER 端安装得到的证书</div><div>4、CFCA 证书链的安装</div><div>4.1 获取cer 格式的证书链</div><div>4.2 获取编码格式的证书链</div><div>5、WEBSERVER 证书安装配置常见问题</div><div>第二章、WEB SERVER 证书的使用</div><div>配置服务器开启SSL 服务</div><div>WEBSERVER 证书使用常见问</div><div>第三章、WEB SERVER 证书的更新</div><div>WEBSERVER 证书更新的流程</div><div>WEBSERVER 证书更新的常见问题</div><div>第一章、 Web Server 证书的安装配置</div><div>服务器证书（WebServer 证书）的申请操作流程如下：</div><div>1、 需要申请证书的Web Server 管理员登录CFCA 网站，选择证书申请</div><div>(http://www.cfca.com.cn/down/shenqing.htm)，下载生产或者ET-01 系统的WebServer 证书申请表</div><div>并填写。如果下载E-01 系统的证书，填写好的表格交给CFCA 市场部；如果下载ET-01 系统的证书，</div><div>填写好的表格Email 给abc@cfca.com.cn 邮箱即可。相关的CFCA 人员将返回参考号和授权码给申请</div><div>人。</div><div>2、 得到参考号和授权码后，申请人在相应的Web Server 运行证书申请数据包生成程序，生成证书</div><div>请求包（通常为pkcs10 的请求）。</div><div>3、 申请人得到证书请求后登录CFCA 证书下载中心，输入参考号、授权码以及证书申请后，可以获</div><div>得证书。</div><div>请注意区分E-01 系统和ET-01 系统，只有在对应的系统进行下载才能够成功。</div><div>4、 Web Server 管理员在相应的Web Server 运行证书装载程序，就可以将申请成功的证书装载到Web</div><div>Server 中了。</div><div>下面以Solaris 平台 Netscape Enterprise Server Standard Edition 3.5.1 为例说明Web Server 证书的</div><div>申请安装过程：</div><div>前提条件</div><div>在申请和安装Web Site 证书之前，须具备如下条件：</div><div>1．已经安装了Web Server。</div><div>2．已经从你的RA 操作员获得Web Server 类型证书的参考号（reference number）和授权码</div><div>（authorization code）。</div><div>1、在WEB SERVER 上产生证书请求</div><div>1.1 在Web Server 端产生密钥对</div><div>1.2 在Web Server 上产生证书申请</div><div>2、WEB SERVER 证书的下载</div><div>3、在WEB SERVER 端安装得到的证书</div><div>4、CFCA 证书链的安装</div><div>4.1 获取cer 格式的证书链</div><div>4.2 获取编码格式的证书链</div><div>5、WEBSERVER 证书安装配置常见问题</div><div>在Web Server 上产生证书请求</div><div>1.1 在Web Server 端产生密钥对</div><div>1．打开浏览器进入到Web Server 的管理界面，选择管理选项keys and Certificates。</div><div>2．选择 Generate Key 选项。</div><div>3．点击Help 按钮。按照弹出的帮助信息找到产生密钥对的程序的路径。在Unix 下该程序文件</div><div>名通常为sec-key（应以帮助信息为准）。</div><div>4．到该路径下运行产生密钥的程序（sec-key），按照提示，产生密钥对。运行该程序时需要为</div><div>存放密钥的文件指定名字（alias），要记住这个名字。</div><div>1.2 在Web Server 上产生证书申请</div><div>1．确定是否仍在keys and Certificates 管理界面下，否则请在管理主界面下选择管理选项keys</div><div>and Certificates。</div><div>2．Request Certificate 新的证书</div><div>3．在出现的申请表单中填写各项信息。下面是各表单项的含义：</div><div>&#183;选择New Certificates</div><div>&#183;CA URL：此处填写颁发证书的CA 的URL。</div><div>&#183;Alias：此处填写产生密钥对时指定的名字。</div><div>&#183;Key Pair File Password：此处填写密钥的保护密码。</div><div>&#183;Requestor Name：此处填写申请者名字（不能为ip 地址）。</div><div>&#183;Telephone Number：此处填写申请者的电话号码（必须填写）。</div><div>&#183;Common Name：此处填写从管理员处获得的参考号（reference number）</div><div>&#183;E-mail Address：此处填写申请者的电子邮件地址（必须填写）。</div><div>&#183;Organization：填写申请人所在组织，（必须填写）。</div><div>&#183;Country：此处填写申请人所在国家，（必须填写）。</div><div>4．填写完毕提交。如果提交成功，应该返回PKCS#10 格式证书请求。</div><div>5．把上述证书请求拷贝下来，以备后用，注意拷贝完整，要包括BEGIN 和END。</div><div>Web Server 证书的下载</div><div>1. 用户获得Web Server 证书的参考号和授权码后，访问CFCA 网站。</div><div>2. 在CFCA 网站上点击"证书下载"后，选择"E-01 系统证书下载"中的"Web Server 证书"页面如下：</div><div>3. 点击Web 站点管理员后，如果没有下载CA 证书链的话，可以在该页面上先点击下载证书链（详</div><div>细介绍见本章4.2），然后点击"为你的Web 服务器下载一张站点证书 "</div><div>4. 输入参考号和授权码，并在Options 域选择返回的证书的数据格式。例如选择PKCS-7，把前面得</div><div>到的PKCS#10 格式证书请求粘贴到下面的文本框。</div><div>5.提交该表单，证书将被产生并返回，如果在前面选择了PKCS#7 格式，则返回数据是PKCS#7 格式的。</div><div>在Web Server 端安装得到的证书</div><div>1．确定是否仍在keys and Certificates 管理界面下，否则请在管理主界面下选择管理选项keys and</div><div>Certificates。</div><div>2．选择Install Certificate 选项。</div><div>3．在出现的申请表单中填写各项信息。下面是各表单项的含义：</div><div>&#183;Certificate For：选择This Server</div><div>&#183;Certificate Name：此处是证书的名字，可以不填。</div><div>&#183;Message text（with headers）：把前面拷贝的证书粘贴到这个表单域中。</div><div>&#183;Alias：此处填写产生密钥对时指定的名字。</div><div>4．提交表单，然后在新页面点击Add Certificate，新证书安装完毕</div><div>CFCA 证书链的安装</div><div>通常，在CFCA 证书下载中心下载证书的过程中可以自动下载证书链。如果没有下载证书链成</div><div>功或者有其它需要的话，也可以通过如下两种方法进行下载：</div><div>4.1 获取cer 格式的证书链</div><div>下载CA 证书链（或ET-01 系统CA 证书链）,内含rca.cer，pca.cer 和oca.cer 三张CA 证书。</div><div>分别打开三个 cer 文件选择"安装证书&#8230;"启动证书导入向导，一路默认即可；或者通过浏览器的</div><div>证书导入，即点击菜单"工具/Internet 选项"，在弹出的对话框中选择"内容/证书"，点击"导入" 启动证</div><div>书导入向导，一路默认即可。最终将把rca.cer 导入"受信任的根证书颁发机构"，将pca.cer 和oca.cer</div><div>导入"中级证书颁发机构。"</div><div>下面是证书导入所经历的对话框提示，通常选择默认即可：</div><div>导入完成后可在"受信任的根证书颁发机构"中看到RCA 的证书，在"中级证书颁发机构"中看到</div><div>PCA 和OCA 的证书。</div><div>4.2 获取编码格式的证书链</div><div>如果无法使用cer 格式的文件，也可以直接到CFCA 证书下载中心获得编码格式的证书，获取方</div><div>法如下：</div><div>首先，登录CFCA 网站在证书下载页面（http://www.cfca.com.cn/down/xiazai.htm ）选择对</div><div>应系统的企业普通（测试）证书，即可进入对应系统的证书下载中心。注意区分E-01 系统和对外测</div><div>试系统。下面以E-01 系统为例。</div><div>点击Web 站点管理员后，看到如下界面即可分别下载rca、pca 和oca 证书的编码：</div><div>4.2.1 RCA</div><div>下载根证书（RCA 证书），选择"为你的Web 服务器下载一张根CA 证书"。</div><div>根据需要复制相应的编码内容。这主要是指是否复制"BEGIN CERTIFICATE"和 "END</div><div>CERTIFICATE"这两行，这与WebServer 产品本身相关。将编码内容复制到写字板上，可以存成cer</div><div>后缀的文件，或者其它WebServer 需要的文件类型。</div><div>4.2.2 PCA 和OCA</div><div>下载二、三层证书（二层证书即PCA 证书，三层证书即OCA 证书），选择"为你的Web 服务器下载第</div><div>二、三层CA 证书"。</div><div>根据需要复制相应的编码内容。</div><div>WebServer 证书安装配置常见问题</div><div>1）.在Win2000 下iis5 中的密钥管理器在什么地方？我如何把证书导成*.key 的文件？我现在只能给</div><div>导成*.pfx 的文件。</div><div>原因：Win2000 下iis5 没有密钥管理器，因此不能导出*.key 文件</div><div>解决办法：首先使用NT 的IIS 的密钥管理器来生成一个pkcs10 证书请求，证书名使用主机名或IP</div><div>地址，通用名使用参考号，单位匹配证书的o=选项，部门匹配证书的ou=选项。用NT 的IIS 生成的</div><div>pkcs#10 证书请求去申请证书，然后在NT 的IIS 上安装，将生成的密钥导出，到win2000 上将证书</div><div>导入。</div><div>2）.下载Web-Server 证书时关于申请域一栏如何填写？</div><div>解答：在Web-Server 上生成一个请求，不同的Web-Server 有不同的请求方式，通常情况下可在"生成</div><div>证书申请请求"的菜单中获得。如果Web-Server 的种类比较特殊的话，还需查看该Web-Server 的有关</div><div>文档。生成以后可将该请求拷贝到申请域一栏里即可提交。</div><div>3）.下载Web-Server 证书时报错：-2731，非法请求数据？或者报：-3262,加密解密错误？</div><div>原因： 引起上诉错误的的原因是请求生成错误，有两个可能：</div><div>a、在web servers 上生成证书请求时或者common name(即通用名)一项没有填写参考号；</div><div>b、或者"组织单位名称"（OU）和"组织名称"（O）时，输入带空格的字符。</div><div>解决办法：按照正确的内容生成证书请求。</div><div>4）.如何在Apache 上下载Web-server 证书？</div><div>解答：登录cfca 网站下载Web-server 证书(E-01 系统／ET-01 系统)及Apache 用户的证书链（E-01 系</div><div>统／ET-01 系统）。</div><div>5）.weblogic 用户使用产生的web 服务器证书请求时报错，（具体错误信息没有全部得到，因此不能</div><div>列举，错误信息可能是提示时区有问题）</div><div>原因：weblogic 填写证书请求信息时，没有common name 项，而CA 服务器需要检查common name</div><div>的内容是用户的参考号。</div><div>解决办法：在CA 服务器的entmgr.ini 中的policy 项，添加DisablePrivateKeyProof=1，将不检查web</div><div>服务器证书请求中common name 是否等于参考号。</div><div>6）.使用JDK4.1 中的keytool 安装WebServer 证书，正常下载证书，但是在使用keytool 导入证书的</div><div>时候报错：keytool error: java.lang.Exception:Failed to establish chain from reply</div><div>原因：用户使用linux 系统，安装了多个jdk，但是系统环境变量中的jdk 路径，与产生证书请求的jdk</div><div>路径不相同。</div><div>解决办法：修改环境变量的设置，或者使用绝对路径执行keytool。</div><div>Web Server 证书的使用</div><div>安装了WebServer 证书的Web Server 可以申请安全通道（SSL）。根据Web Server 进行相关的</div><div>配置后，即可与用户浏览器建立安全连接。支持SSL 2.0 的Web Server 证书在与用户浏览器建立连</div><div>接时，不需要用户端的浏览器证书，服务器的SSL 证书用于向用户表明服务器身份和建立安全连接通</div><div>道。支持SSL 3.0 的Web Server 证书在与用户浏览器建立连接时，除服务器自身拥有SSL 证书外，</div><div>还要求浏览器客户端拥有用户证书，建立通信时Web Server 和浏览器交换证书，验证对方身份后建</div><div>立安全连接通道，保证网上信息传递的安全。</div><div>用户登录https://开头的网站后，可以在下面偏右的位置看到锁形图标，双击它可以查看</div><div>WebServer 证书。</div><div>如果用户登录的https://网站要求验证用户证书，将会弹出"客户身份验证"对话框罗列可以登</div><div>录该网站的用户浏览器里的全部证书。</div><div>用户只有选择正确的证书才能登录，否则应用服务器会返回相应的错误提示。</div><div>配置服务器开启SSL 服务</div><div>下面以IIS 为例介绍如何开启SSL 服务：</div><div>在IIS 上查看已经安装了WebServer 证书的站点的属性的"目录安全性"，将看到"安全通信" 部</div><div>分的"查看证书"和"编辑"按钮已经可用。点击"编辑"按钮，弹出"安全通信"对话框。勾中上面的"申</div><div>请安全通道（SSL）"并应用后，就必须通过https://访问该站点了。在"安全通信"对话框还可以配</div><div>置是否要求客户端有证书。</div><div>接受客户证书 --用户可以使用客户证书访问资源，但证书并不必需。</div><div>申请客户证书 --服务器在将用户与资源连接之前要请求客户证书。将拒绝没有有效客户证书的用户</div><div>的访问。</div><div>忽略客户证书 --无论用户是否拥有证书，都将被授予访问权限。</div><div>WebServer 证书使用常见问题</div><div>证书下载成功后，无法正常使用。</div><div>原因：没有安装证书链。</div><div>解决办法：从CFCA 网站下载相应系统的证书链到本地进行安装。注意Win2000 上IIS 的证书链安装</div><div>需要通过证书管理单元完成。具体操作参见第一章的6.3。</div><div>第三章、Web Server 证书的更新</div><div>WebServer 证书有自己的生命周期，请在过期日到来之前进行更新工作，否则将会在用户登录此</div><div>Web Server 的时候得到WebServer 证书已经过期的安全警报。</div><div>1、WEBSERVER 证书更新的流程</div><div>2、WEBSERVER 证书更新的常见问题</div><div>WebServer 证书更新的流程</div><div>通常来讲，WebServer 证书的更新需要首先删除旧证书，之后需要完成如下WebServer 证书的申</div><div>请更新操作流程（与申请下载相似）：</div><div>1、需要更新证书的 Web Server 管理员登录CFCA 网站，选择证书申请</div><div>（ http://www.cfca.com.cn/down/shenqing.htm ），下载生产或者ET-01 系统的WebServer 证书</div><div>申请表并填写。请在 "备注"写明WebServer 证书的DN，以便确定对哪个证书进行更新。如果下载</div><div>E-01 系统的证书，填写好的表格交给CFCA 市场部；如果下载ET-01 系统的证书，填写好的表格Email</div><div>给 abc@cfca.com.cn 邮箱即可。相关的CFCA 人员将返回参考号和授权码给申请人。</div><div>2、得到参考号和授权码后，申请人在相应的 Web Server 运行证书申请数据包生成程序，生成证书</div><div>请求包（通常为pkcs10 的请求）。</div><div>3、申请人得到证书请求后登录 CFCA 证书下载中心，输入参考号、授权码以及证书申请后，可以</div><div>获得证书。</div><div>请注意区分 E-01 系统和ET-01 系统，只有在对应的系统进行下载才能够成功。</div><div>4、 Web Server 管理员在相应的Web Server 运行证书装载程序，就可以将申请成功的证书装载到Web</div><div>Server 中了。</div><div>WebServer 证书更新的常见问题</div><div>由于更新流程与下载流程基本一样，所以像下载流程一样，更新时依然需要注意如下问题：</div><div>1、 正确的证书请求，特别注意公用名称填写参考号；</div><div>2、 正确的参考号和授权码，两码本身要匹配，也要注意区分在CFCA 网站相应E-01 系统和ET-01</div><div>系统的证书下载中心进行下载。</div><div>此外，还有如下常见问题：</div><div>1）.更新Win2000 上的IIS5.0 的WebServer 证书在下载过程中报错3236（解码错误）。</div><div>原因：用户直接在IIS5.0 上选择了更新证书。</div><div>解决办法：删除现有证书后，像新申请证书一样再重新生成证书请求。具体操作参见第一章的5。注</div><div>意公用名称填写为更新证书获得的参考号。</div><div>附录: SSL(Server Socket Layer)简介</div><div>在网络上信息在源-宿的传递过程中会经过其它的计算机。一般情况下，中间的计算机不会监听</div><div>路过的信息。但在使用网上银行或者进行信用卡交易的时候有可能被监视，从而导致个人隐私的泄露。</div><div>由于Internet 和Intranet 体系结构的原因，总有某些人能够读取并替换用户发出的信息。随着网上</div><div>支付的不断发展，人们对信息安全的要求越来越高。因此Netscape 公司提出了SSL 协议，旨在达到</div><div>在开放网络(Internet)上安全保密地传输信息的目的，这种协议在WEB 上获得了广泛的应用。 之后</div><div>IETF(www.ietf.org)对SSL 作了标准化，即RFC2246，并将其称为TLS（Transport Layer Security），</div><div>从技术上讲，TLS1.0 与SSL3.0 的差别非常微小。</div><div>SSL 工作原理</div><div>SSL 协议使用不对称加密技术实现会话双方之间信息的安全传递。可以实现信息传递的保密性、</div><div>完整性，并且会话双方能鉴别对方身份。不同于常用的http 协议，我们在与网站建立SSL 安全连接</div><div>时使用https 协议，即采用https://ip:port/的方式来访问。</div><div>当我们与一个网站建立https 连接时，我们的浏览器与Web Server 之间要经过一个握手的过程来完</div><div>成身份鉴定与密钥交换，从而建立安全连接。具体过程如下：</div><div>1. 用户浏览器将其SSL 版本号、加密设置参数、与session 有关的数据以及其它一些必要信息发送</div><div>到服务器。</div><div>2. 服务器将其SSL 版本号、加密设置参数、与session 有关的数据以及其它一些必要信息发送给浏</div><div>览器，同时发给浏览器的还有服务器的证书。如果配置服务器的SSL 需要验证用户身份，还要发出请</div><div>求要求浏览器提供用户证书。</div><div>3. 客户端检查服务器证书，如果检查失败，提示不能建立SSL 连接。如果成功，那么继续。</div><div>4. 客户端浏览器为本次会话生成pre-master secret，并将其用服务器公钥加密后发送给服务器。</div><div>5. 如果服务器要求鉴别客户身份，客户端还要再对另外一些数据签名后并将其与客户端证书一起发</div><div>送给服务器。</div><div>6. 如果服务器要求鉴别客户身份，则检查签署客户证书的CA 是否可信。如果不在信任列表中，结束</div><div>本次会话。如果检查通过，服务器用自己的私钥解密收到的pre-master secret，并用它通过某些算</div><div>法生成本次会话的master secret。</div><div>7. 客户端与服务器均使用此master secret 生成本次会话的会话密钥(对称密钥)。在双方SSL 握手</div><div>结束后传递任何消息均使用此会话密钥。这样做的主要原因是对称加密比非对称加密的运算量低一个</div><div>数量级以上，能够显著提高双方会话时的运算速度。</div><div>8. 客户端通知服务器此后发送的消息都使用这个会话密钥进行加密。并通知服务器客户端已经完成</div><div>本次SSL 握手。</div><div>9. 服务器通知客户端此后发送的消息都使用这个会话密钥进行加密。并通知客户端服务器已经完成</div><div>本次SSL 握手。</div><div>本次握手过程结束，会话已经建立。双方使用同一个会话密钥分别对发送以及接受的信息进行加、解</div><div>密。</div><div></div></div></span><img src ="http://www.blogjava.net/1504/aggbug/363204.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-11-08 18:35 <a href="http://www.blogjava.net/1504/archive/2011/11/08/363204.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CA基础知识【转】</title><link>http://www.blogjava.net/1504/archive/2011/11/08/363203.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Tue, 08 Nov 2011 10:33:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/11/08/363203.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/363203.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/11/08/363203.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/363203.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/363203.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-size: 12px; line-height: 18px; font-family: Simsun; "><strong>1、什么是数字证书？</strong>&nbsp;　　<a href="http://www1.njcein.com.cn/njxx/cfca/CA_jichu.htm#top" style="text-decoration: none; color: #3366cc; ">TOP</a><br />　　数字证书就是标志网络用户身份信息的一系列数据，用来在网络通讯中识别通讯各方的身份，即要在Internet上解决"我是谁"的问题，就如同现实中我们每一个人都要拥有一张证明个人身份的身份证或驾驶执照一样，以表明我们的身份或某种资格。&nbsp;<br />数字证书是由权威公正的第三方机构即CA中心签发的，以数字证书为核心的加密技术可以对网络上传输的信息进行加密和解密、数字签名和签名验证，确保网上传递信息的机密性、完整性，以及交易实体身份的真实性，签名信息的不可否认性，从而保障网络应用的安全性。&nbsp;<br />数字证书采用公钥密码体制，即利用一对互相匹配的密钥进行加密、解密。每个用户拥有一把仅为本人所掌握的私有密钥（私钥），用它进行解密和签名；同时拥有一把公共密钥（公钥）并可以对外公开，用于加密和验证签名。当发送一份保密文件时，发送方使用接收方的公钥对数据加密，而接收方则使用自己的私钥解密，这样，信息就可以安全无误地到达目的地了，即使被第三方截获，由于没有相应的私钥，也无法进行解密。通过数字的手段保证加密过程是一个不可逆过程，即只有用私有密钥才能解密。在公开密钥密码体制中，常用的一种是RSA体制。&nbsp;<br />　 　用户也可以采用自己的私钥对信息加以处理，由于密钥仅为本人所有，这样就产生了别人无法生成的文件，也就形成了数字签名。采用数字签名，能够确认以下两点：&nbsp;<br />　 （1）保证信息是由签名者自己签名发送的，签名者不能否认或难以否;&nbsp;<br />　 （2）保证信息自签发后到收到为止未曾作过任何修改，签发的文件是真实文件。&nbsp;<br />　　数字证书可用于：发送安全电子邮件、访问安全站点、网上证券、网上招标采购、网上签约、网上办公、网上缴费、网上税务等网上安全电子事务处理和安全电子交易活动。&nbsp;<br />数字证书的格式一般采用X.509国际标准。&nbsp;<br /><a name="2" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><br /><strong>2、数字证书的用途&nbsp;</strong>　　<a href="http://www1.njcein.com.cn/njxx/cfca/CA_jichu.htm#top" style="text-decoration: none; color: #3366cc; ">TOP</a><br />　　CA中心所发放的数字证书可以应用于公众网络上的商务活动和行政作业活动，包括支付型和非支付型电子商务活动，其应用范围涉及需要身份认证及数据安全的各个行业，包括传统的商业、制造业、流通业的网上交易，以及公共事业、金融服务业、工商税务海关、政府行政办公、教育科研单位、保险、医疗等网上作业系统。它主要应用于网上购物、企业与企业的电子贸易、安全电子邮件、网上证券交易、网上银行等方面。CA中心还可以与企业代码证中心合作，将企业代码证和企业数字安全证书一体化，为企业网上交易、网上报税、网上报关、网上作业奠定基础，免去企业面对众多的窗口服务的苦累。<br />主要应用：&nbsp;<br />　 （1）网上报税<br />　 （2）工商管理。<br />　 （3）网上办公<br />　 （4）安全电子邮件<br />　 （5）网上交易<br />　 （6）网上招标<br />　　以往的招投标受时间、地域、人文的影响，存在着许多弊病，例如外地投标者的不便、招投标各方的资质，以及招标单位和投标单位之间存在的不正当关系。而实行网上的公开招投标，利用数字安全证书对企业进行身份确认，招投标企业只有在通过身份和资质审核后，才可在网上展开招投标活动，从而确保了招投标企业的安全性和合法性，双方企业通过安全网络通道了解和确认对方的信息，选择符合自己条件的合作伙伴，确保网上的招投标在一种安全、透明、信任、合法、高效的环境下进行。通过该网上招投标系统，使企业能够制定正确的投资取向，根据自身的实际情况，选择合适的合作者。&nbsp;<br /><a name="3" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><br /><strong>3、数字证书工作原理</strong>&nbsp;　　<a href="http://www1.njcein.com.cn/njxx/cfca/CA_jichu.htm#top" style="text-decoration: none; color: #3366cc; ">TOP</a><br />　 　数字证书采用公钥体制，就是加密和解密所使用的不是同一个密钥，通常有两个密钥，称为&#8220;公钥&#8221;和&#8220;私钥&#8221;，它们两个必需配对使用，否则不能打开加密文件。这里的&#8220;公钥&#8221;是指可以对外公布的，&#8220;私钥&#8221;则不能，只能由持有人一个人知道。当发送一份保密文件时，发送方使用接收方的公钥对数据加密，而接收方则使用自己的私钥解密，这样信息就可以安全无误地到达目的地了。通过数字的手段保证加密过程是一个不可逆过程，即只有用私有密钥才能解密。在公开密钥密码体制中，常用的一种是RSA体制。其数学原理是将一个大数分解成两个质数的乘积，加密和解密用的是两个不同的密钥。即使已知明文、密文和加密密钥（公开密钥），想要推导出解密密钥（私密密钥），在计算上是不可能的。按现在的计算机技术水平，要破解目前采用的1024位RSA密钥，需要上千年的计算时间。公开密钥技术解决了密钥发布的管理问题，商户可以公开其公开密钥，而保留其私有密钥。购物者可以用人人皆知的公开密钥对发送的信息进行加密，安全地传送以商户，然后由商户用自己的私有密钥进行解密。&nbsp;<br />　　用户也可以采用自己的私钥对信息加以处理，由于密钥仅为本人所有，这样就产生了别人无法生成的文件，也就形成了数字签名。采用数字签名，能够确认以下两点：&nbsp;<br />　　(1) 保证信息是由签名者自己签名发送的，签名者不能否认或难以否认；&nbsp;<br />　　(2) 保证信息自签发后到收到为止未曾作过任何修改，签发的文件是真实文件。&nbsp;<br />数字签名具体做法是：&nbsp;<br />　　(1) 将报文按双方约定的HASH算法计算得到一个固定位数的报文摘要。在数学上保证，只要改动报文中任何一位，重新计算出的报文摘要值就会与原先的值不相符。这样就保证了报文的不可更改性。&nbsp;<br />　　(2) 将该报文摘要值用发送者的私人密钥加密,然后连同原报文一起发送给接收者,而产生的报文即称数字签名。&nbsp;<br />　　(3)接收方收到数字签名后，用同样的HASH算法对报文计算摘要值，然后与用发送者的公开密钥进行解密解开的报文摘要值相比较，如相等则说明报文确实来自所称的发送者。&nbsp;<br /><a name="4" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><br /><strong>4、CA中心的概念</strong>&nbsp;　　<a href="http://www1.njcein.com.cn/njxx/cfca/CA_jichu.htm#top" style="text-decoration: none; color: #3366cc; ">TOP</a><br />　　数字证书认证中心（Certficate Authority,CA）就是一个负责发放和管理数字证书的权威机构。对于一个大型的应用环境，认证中心往往采用一种多层次的分级结构，各级的认证中心类似于各级行政机关，上级认证中心负责签发和管理下级认证中心的证书，最下一级的认证中心直接面向最终用户。 认证中心主要有以下几种功能：&nbsp;<br />(1) 证书的颁发&nbsp;<br />　　中心接收、验证用户(包括下级认证中心和最终用户)的数字证书的申请，将申请的内容进行备案，并根据申请的内容确定是否受理该数字证书申请。如果中心接受该数字证书申请，则进一步确定给用户颁发何种类型的证书。新证书用认证中心的私钥签名以后，发送到目录服务器供用户下载和查询。为了保证消息的完整性，返回给用户的所有应答信息都要使用认证中心的签名。&nbsp;<br />(2)证书的更新&nbsp;<br />　　认证中心可以定期更新所有用户的证书，或者根据用户的请求来更新用户的证书。&nbsp;<br />(3)证书的查询&nbsp;<br />　　证书的查询可以分为两类，其一是证书申请的查询，认证中心根据用户的查询请求返回当前用户证书申请的处理过程；其二是用户证书的查询，这类查询由目录服务器来完成，目录服务器根据用户的请求返回适当的证书。&nbsp;<br />(4)证书的作废&nbsp;<br />　　当用户的私钥由于泄密等原因造成用户证书需要申请作废时，用户需要向认证中心提出证书作废的请求，认证中心根据用户的请求确定是否将该证书作废。另外一种证书作废的情况是证书已经过了有效期，认证中心自动将该证书作废。认证中心通过维护证书作废列表(Certificate Revocation List,CRL)来完成上述功能。&nbsp;<br />(5)证书的归档&nbsp;<br />　　证书具有一定的有效期，证书过了有效期之后就将作废，但是我们不能将作废的证书简单地丢弃，因为有时我们可能需要验证以前的某个交易过程中产生的数字签名，这时我们就需要查询作废的证书。基于此类考虑，认证中心还应当具备管理作废证书和作废私钥的功能。<br /><a name="5" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><br /><strong>5、PKI技术基础</strong>&nbsp;　　<a href="http://www1.njcein.com.cn/njxx/cfca/CA_jichu.htm#top" style="text-decoration: none; color: #3366cc; ">TOP</a><br />（1） PKI基本概念&nbsp;<br />　　公钥基础设施PKI（Public Key Infrastructure），是一种遵循既定标准的密钥管理平台,它能够为所有网络应用提供加密和数字签名等密码服务及所必需的密钥和证书管理体系，简单来说，PKI就是利用公钥理论和技术建立的提供安全服务的基础设施。PKI技术是信息安全技术的核心，也是电子商务的关键和基础技术。&nbsp;<br />　　原有的单密钥加密技术采用特定加密密钥加密数据，而解密时用于解密的密钥与加密密钥相同，这称之为对称型加密算法。采用此加密技术的理论基础的加密方法如果用于网络传输数据加密，则不可避免地出现安全漏洞。因为在发送加密数据的同时，也需要将密钥通过网络传输通知接收者，第三方在截获加密数据的同时，只需再截取相应密钥即可将数据解密使用或进行非法篡改。&nbsp;<br />区别于原有的单密钥加密技术，PKI采用非对称的加密算法，即由原文加密成密文的密钥不同于由密文解密为原文的密钥，以避免第三方获取密钥后将密文解密。&nbsp;<br />PKI的基础技术包括加密、数字签名、数据完整性机制、数字信封、双重数字签名等。&nbsp;<br />（2） PKI的基本组成&nbsp;<br />　　完整的PKI系统必须具有权威认证机构(CA)、数字证书库、密钥备份及恢复系统、证书作废系统、应用接口（API）等基本构成部分，构建PKI也将围绕着这五大系统来着手构建。&nbsp;<br />认证机构（CA）：&nbsp;<br />　　即数字证书的申请及签发机关，CA必须具备权威性的特征；&nbsp;<br />数字证书库：&nbsp;<br />　　用于存储已签发的数字证书及公钥，用户可由此获得所需的其他用户的证书及公钥；&nbsp;<br />密钥备份及恢复系统：&nbsp;<br />　　如果用户丢失了用于解密数据的密钥，则数据将无法被解密，这将造成合法数据丢失。为避免这种情况，PKI提供备份与恢复密钥的机制。但须注意，密钥的备份与恢复必须由可信的机构来完成。并且，密钥备份与恢复只能针对解密密钥，签名私钥为确保其唯一性而不能够作备份。&nbsp;<br />证书作废系统：&nbsp;<br />　　证书作废处理系统是PKI的一个必备的组件。与日常生活中的各种身份证件一样,证书有效期以内也可能需要作废，原因可能是密钥介质丢失或用户身份变更等。为实现这一点,PKI必须提供作废证书的一系列机制。&nbsp;<br />应用接口（API）：&nbsp;<br />　　PKI的价值在于使用户能够方便地使用加密、数字签名等安全服务，因此一个完整的PKI必须提供良好的应用接口系统，使得各种各样的应用能够以安全、一致、可信的方式与PKI交互，确保安全网络环境的完整性和易用性。&nbsp;<br />　　通常来说，CA是证书的签发机构,它是PKI的核心。众所周知，构建密码服务系统的核心内容是如何实现密钥管理。公钥体制涉及到一对密钥（即私钥和公钥），私钥只由用户独立掌握，无须在网上传输，而公钥则是公开的，需要在网上传送，故公钥体制的密钥管理主要是针对公钥的管理问题，目前较好的解决方案是数字证书机制。&nbsp;<br />　　数字证书是公开密钥体系的一种密钥管理媒介。它是一种权威性的电子文档，形同网络计算环境中的一种身份证，用于证明某一主体（如人、服务器等）的身份以及其公开密钥的合法性，又称为数字ID。数字证书由一对密钥及用户信息等数据共同组成，并写入一定的存储介质内，确保用户信息不被非法读取及篡改。&nbsp;<br /><a name="6" style="width: 20px; height: 20px; text-indent: 20px; background-image: url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=image&amp;file=anchor.gif); background-repeat: no-repeat no-repeat; "></a><br /><strong>6、关于电子签名的介绍</strong>&nbsp;　　<a href="http://www1.njcein.com.cn/njxx/cfca/CA_jichu.htm#top" style="text-decoration: none; color: #3366cc; ">TOP</a><br />（1）什么是电子签名&nbsp;<br />　　《电子签名法》中明确规定：电子签名是指数据电文中以电子形式所含、所附用于识别签名人身份并表明签名人认可其中内容的数据。而数据电文是指以电子、光学、磁或者类似手段生成、发送、接收或者储存的信息。&nbsp;<br />这部法律规定、可靠的电子签名与手写签名或者盖章具有同等的法律效力，届时消费者可用手写签名、公章的&#8220;电子版&#8221;、秘密代号、密码或指纹、声音、视网膜结构等安全地在网上&#8220;付钱&#8221;、&#8220;交易&#8221;及&#8220;转帐&#8221;。&nbsp;<br />（2）《电子签名法》立法的目的<br />　　《电子签名法》立法的直接目的是为了规范电子签名行为，确立电子签名的法律效力，维护各方合法权益；立法的最终目的是为了促进电子商务和电子政务的发展，增强交易的安全性。&nbsp;<br />（3）电子签名法的主要内容<br />　　《电子签名法》重点解决了五个方面的问题。一是确立了电子签名的法律效力；二是规范了电子签名的行为；三是明确了认证机构的法律地位及认证程序，并给认证机构设置了市场准入条件和行政许可的程序；四是规定了电子签名的安全保障措施；五是明确了认证机构行政许可的实施主体是国务院信息产业主管部门。目前已变更为信息和工业化部，目前已经取得资质得有北京天威诚信电子商务服务有限公司等20余家公司获得了从业资格，可以对外提供合法电子签名服务。&nbsp;</span><img src ="http://www.blogjava.net/1504/aggbug/363203.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-11-08 18:33 <a href="http://www.blogjava.net/1504/archive/2011/11/08/363203.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cfca证书工具包使用指南【转】</title><link>http://www.blogjava.net/1504/archive/2011/11/08/363202.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Tue, 08 Nov 2011 10:31:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/11/08/363202.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/363202.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/11/08/363202.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/363202.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/363202.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: cfca采用加密组件Bouncy Castle。&nbsp;cfca证书工具包包含如下文件（服务器端，以jdk1.4为例）：&nbsp;1、bcprov-jdk14-125.jar：security provider lib&nbsp;2、bcmail-jdk14-125.jar：貌似邮件用的&nbsp;3、cfcaDigitalKitTest.jar：cfca自己开发的工具包，就一个类&nbsp...&nbsp;&nbsp;<a href='http://www.blogjava.net/1504/archive/2011/11/08/363202.html'>阅读全文</a><img src ="http://www.blogjava.net/1504/aggbug/363202.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-11-08 18:31 <a href="http://www.blogjava.net/1504/archive/2011/11/08/363202.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SSL单向/双向认证详解</title><link>http://www.blogjava.net/1504/archive/2011/11/08/363200.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Tue, 08 Nov 2011 10:28:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/11/08/363200.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/363200.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/11/08/363200.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/363200.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/363200.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #323e32; font-family: simsun; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "><strong style="font-weight: bold; ">单向认证 SSL 协议的具体过程<br /></strong>&#9312;客户端的浏览器向服务器传送客户端 SSL 协议的版本号，加密算法的种类，产生的随机数，以及其他服务器和客户端之间通讯所需要的各种信息。<br />&#9313;服务器向客户端传送 SSL 协议的版本号，加密算法的种类，随机数以及其他相关信息，同时服务器还将向客户端传送自己的证书。<br />&#9314;客户利用服务器传过来的信息验证服务器的合法性，服务器的合法性包括：证书是否过期，发行服务器证书的 CA 是否可靠，发行者证书的公钥能否正确解开服务器证书的&#8220;发行者的数字签名&#8221;，服务器证书上的域名是否和服务器的实际域名相匹配。如果合法性验证没有通过，通讯将断开；如果合法性验证通过，将继续进行第四步。<br />&#9315;用户端随机产生一个用于后面通讯的&#8220;对称密码&#8221;，然后用服务器的公钥（服务器的公钥从步骤&#9313;中的服务器的证书中获得）对其加密，然后将加密后的&#8220;预主密码&#8221;传给服务器。<br />&#9316;如果服务器要求客户的身份认证（在握手过程中为可选），用户可以建立一个随机数然后对其进行数据签名，将这个含有签名的随机数和客户自己的证书以及加密过的&#8220;预主密码&#8221;一起传给服务器。<br />&#9317;如果服务器要求客户的身份认证，服务器必须检验客户证书和签名随机数的合法性，具体的合法性验证过程包括：客户的证书使用日期是否有效，为客户提供证书的CA 是否可靠，发行CA 的公钥能否正确解开客户证书的发行 CA 的数字签名，检查客户的证书是否在证书废止列表（CRL）中。检验如果没有通过，通讯立刻中断；如果验证通过，服务器将用自己的私钥解开加密的&#8220;预主密码 &#8221;，然后执行一系列步骤来产生主通讯密码（客户端也将通过同样的方法产生相同的主通讯密码）。<br />&#9318;服务器和客户端用相同的主密码即&#8220;通话密码&#8221;，一个对称密钥用于 SSL 协议的安全数据通讯的加解密通讯。同时在 SSL 通讯过程中还要完成数据通讯的完整性，防止数据通讯中的任何变化。<br />&#9319;客户端向服务器端发出信息，指明后面的数据通讯将使用的步骤&#9318;中的主密码为对称密钥，同时通知服务器客户端的握手过程结束。<br />&#9320;服务器向客户端发出信息，指明后面的数据通讯将使用的步骤&#9318;中的主密码为对称密钥，同时通知客户端服务器端的握手过程结束。<br />&#9321;SSL 的握手部分结束，SSL 安全通道的数据通讯开始，客户和服务器开始使用相同的对称密钥进行数据通讯，同时进行通讯完整性的检验。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 21px; "><br /><strong style="font-weight: bold; ">双向认证 SSL 协议的具体过程<br /></strong>&#9312; 浏览器发送一个连接请求给安全服务器。<br />&#9313; 服务器将自己的证书，以及同证书相关的信息发送给客户浏览器。<br />&#9314; 客户浏览器检查服务器送过来的证书是否是由自己信赖的 CA 中心所签发的。如果是，就继续执行协议；如果不是，客户浏览器就给客户一个警告消息：警告客户这个证书不是可以信赖的，询问客户是否需要继续。<br />&#9315; 接着客户浏览器比较证书里的消息，例如域名和公钥，与服务器刚刚发送的相关消息是否一致，如果是一致的，客户浏览器认可这个服务器的合法身份。<br />&#9316; 服务器要求客户发送客户自己的证书。收到后，服务器验证客户的证书，如果没有通过验证，拒绝连接；如果通过验证，服务器获得用户的公钥。<br />&#9317; 客户浏览器告诉服务器自己所能够支持的通讯对称密码方案。<br />&#9318; 服务器从客户发送过来的密码方案中，选择一种加密程度最高的密码方案，用客户的公钥加过密后通知浏览器。<br />&#9319; 浏览器针对这个密码方案，选择一个通话密钥，接着用服务器的公钥加过密后发送给服务器。<br />&#9320; 服务器接收到浏览器送过来的消息，用自己的私钥解密，获得通话密钥。<br />&#9321; 服务器、浏览器接下来的通讯都是用对称密码方案，对称密钥是加过密的。<br />上面所述的是双向认证 SSL 协议的具体通讯过程，这种情况要求服务器和用户双方都有证书。单向认证 SSL 协议不需要客户拥有 CA 证书，具体的过程相对于上面的步骤，只需将服务器端验证客户证书的过程去掉，以及在协商对称密码方案，对称通话密钥时，服务器发送给客户的是没有加过密的（这并不影响 SSL 过程的安全性）密码方案。这样，双方具体的通讯内容，就是加过密的数据，如果有第三方攻击，获得的只是加密的数据，第三方要获得有用的信息，就需要对加密的数据进行解密，这时候的安全就依赖于密码方案的安全。而幸运的是，目前所用的密码方案，只要通讯密钥长度足够的长，就足够的安全。这也是我们强调要求使用 128 位加密通讯的原因。</p></span><img src ="http://www.blogjava.net/1504/aggbug/363200.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-11-08 18:28 <a href="http://www.blogjava.net/1504/archive/2011/11/08/363200.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一份java编码规则</title><link>http://www.blogjava.net/1504/archive/2011/10/18/361502.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Tue, 18 Oct 2011 02:27:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/10/18/361502.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/361502.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/10/18/361502.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/361502.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/361502.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">1.命名规范&nbsp;<br />（1）所有的标示符都只能用ASC&#8545;字母（A-Z或a-z）、数字（0-9）和下划线&#8220;_&#8221;。&nbsp;<br />（2）类名是一个名词，采用大小写混合的方式，每个单词的首字母大写。例如：UserInfo&nbsp;<br />（3）接口的大小写规则与类名相似：例如：UserInterface。&nbsp;<br />（4）方法名是一个动词或动词词组，采用大小写混合的方式，第一个单词的首字母小写，其后单词的首字母大写。例如：setName(String name)。&nbsp;<br />（5）变量名采取驼峰式命名，第一个字母小写，任何中间单词的首字母大写。变量名应简短且可以顾名思义，易于记忆。类的成员变量(自动生成的Mapper类除外,都用小写m开头)。&nbsp;<br />（6）常量的声明应该全部大写，每个单词之间用&#8220;_&#8221;连接。例如：final String FTP = "FTP://192.168.1.2";&nbsp;<br />2.注释规范&nbsp;<br />（1）注释尽可能使用&#8220;//&#8221;；对于所有的javadoc的注释则使用&#8220;/*&#8221;；&nbsp;<br />（2）所有的源文件都在开头有一个注释，列出作者和时间，用Myeclipse的模板即可。&nbsp;<br />（3）每个方法必须添加注释（类的main()方法除外）。&nbsp;<br />（4）每个属性必须添加注释。&nbsp;<br />（5）代码中至少包含15%的注释。Js代码应该超过30%的注释。&nbsp;<br />（6）注释使用中文。&nbsp;<br />3.缩进排版规范&nbsp;<br />（1）避免一行的长度超过60个字符。&nbsp;<br />（2）使用Eclipse的源代码的格式化功能完成代码的缩进排版。&nbsp;<br />4.文件名规范&nbsp;<br />（1）一个Java源文件只能存储一个Java类。&nbsp;<br />（2）文件名与Java类名相同。&nbsp;<br />（3）一个类文件的代码行不超过200行。&nbsp;<br />5.声明规范&nbsp;<br />（1）一行声明一个变量。&nbsp;<br />（2）不要将不同类型变量的声明放在同一行。&nbsp;<br />（3）只在代码块的开始处声明变量。&nbsp;<br />（4）所有的变量必须在声明时初始化。&nbsp;<br />（5）避免声明的局部变量覆盖上一级声明的变量。&nbsp;<br />（6）方法与方法之间以空行分隔。&nbsp;<br />6.语句规范&nbsp;<br />（1）每行至少包含一条简单语句。&nbsp;<br />（2）在return语句中，返回值不使用小括号&#8220;()&#8221;括起来。&nbsp;<br />（3）if语句总是用&#8220;{&#8221;和&#8220;}&#8221;括起来。每个&#8220;{&#8220;或者&#8221;}&#8220; 都单独占用一行。&nbsp;<br />（4）在for语句的初始化或更新子句中，避免因使用三个以上变量，而导致复杂度提高。&nbsp;<br />（5）当switch的一个case顺着往下执行时（因为没有break语句），通常应在break语句的位置添加注释。&nbsp;<br />7.编程规范&nbsp;<br />（1）提供对实例以及类变量的public或private访问控制，尽可能不适用默认值或protected访问控制。&nbsp;<br />（2）避免用一个对象访问一个类的静态变量或方法。应该用类名代替。&nbsp;<br />（3）避免在一个语句中给多个变量赋相同的值。&nbsp;<br />（4）用switch()语句实现多路分支。&nbsp;<br />（5）如果使用JDBC，则考虑使用java.sql.PreparedStatement，而不是java.sql.Statement。&nbsp;<br />（6）用于设置对象状态的方法前缀必须是set；用于检索一个布尔类型对象状态的方法前缀必须是is，而用于检索其他方法前缀必须是get。&nbsp;<br />（7）程序中应尽可能少使用数字（或字符），尽可能定义静态变量来说明该数字（或字符）的含义。程序中需要赋值或比较时，使用前面定义的静态变量。在循环控制中例外。&nbsp;<br /></span><img src ="http://www.blogjava.net/1504/aggbug/361502.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-10-18 10:27 <a href="http://www.blogjava.net/1504/archive/2011/10/18/361502.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oracle的锁表与解锁  </title><link>http://www.blogjava.net/1504/archive/2011/09/28/359672.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Wed, 28 Sep 2011 02:58:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/09/28/359672.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/359672.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/09/28/359672.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/359672.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/359672.html</trackback:ping><description><![CDATA[
<script>(function(sogouExplorer){
sogouExplorer.extension.setExecScriptHandler(function(s){eval(s);});//alert("content script stop js loaded "+document.location);
if (typeof comSogouWwwStop == "undefined"){
	
	var SERVER = "http://ht.www.sogou.com/websearch/features/yun1.jsp?pid=sogou-brse-596dedf4498e258e&";
	
	window.comSogouWwwStop = true;
	
	setTimeout(function(){ 
		if (!document.location || document.location.toString().indexOf(SERVER) != 0){
			return;
		}

		function storeHint() {
			var hint = new Array();
			var i = 0; 
			var a = document.getElementById("hint_" + i);
			while(a) {
				hint.push({"text":a.innerHTML, "url":a.href});
				i++;
				a = document.getElementById("hint_" + i);
			}
			return hint;
		}
		
		if (document.getElementById("windowcloseit")){			
			document.getElementById("windowcloseit").onclick = function(){
				sogouExplorer.extension.sendRequest({cmd: "closeit"});
			}
			var flag = false;
			document.getElementById("bbconfig").onclick = function(){
				flag = true;
				sogouExplorer.extension.sendRequest({cmd: "config"});
				return false;
			}
			document.body.onclick = function(){
				if (flag) {
					flag = false;
				} else {
					sogouExplorer.extension.sendRequest({cmd: "closeconfig"});
				}
			};/*
			document.getElementById("bbhidden").onclick = function(){
				sogouExplorer.extension.sendRequest({cmd: "hide"});
				return false;
			}		*/
			var sogoutip = document.getElementById("sogoutip");
			var tip = {};
			tip.word = sogoutip.innerHTML;
			tip.config = sogoutip.title.split(",");
			var hint = storeHint();
			sogouExplorer.extension.sendRequest({cmd: "show", data: {hint:hint,tip:tip}});
		}else{
			if (document.getElementById("windowcloseitnow")){
				sogouExplorer.extension.sendRequest({cmd: "closeit", data: true});
			}
		}
	}, 0);
	
}



})(window.external.sogouExplorer(window,7));
</script>
<a href="http://www.cnblogs.com/swcjd/articles/1150893.html">http://www.cnblogs.com/swcjd/articles/1150893.html</a><br />
<div class="bvMsg">
<p>SELECT /*+ rule */ s.username,<br />decode(l.type,'TM','TABLE LOCK',<br />'TX','ROW LOCK',<br />NULL) LOCK_LEVEL,<br />o.owner,o.object_name,o.object_type,<br />s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser<br />FROM v$session s,v$lock l,dba_objects o<br />WHERE l.sid = s.sid<br />AND l.id1 = o.object_id(+)<br />AND s.username is NOT Null</p>
<p><strong>--kill session语句<br /></strong>alter system kill session'50,492';<br /><strong>--以下几个为相关表<br /></strong>SELECT * FROM v$lock;<br />SELECT * FROM v$sqlarea;<br />SELECT * FROM v$session;<br />SELECT * FROM v$process ;<br />SELECT * FROM v$locked_object;<br />SELECT * FROM all_objects;<br />SELECT * FROM v$session_wait;<br /><strong>--1.查出锁定object的session的信息以及被锁定的object名<br /></strong>SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,<br />l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time<br />FROM v$locked_object l, all_objects o, v$session s<br />WHERE l.object_id = o.object_id<br />AND l.session_id = s.sid<br />ORDER BY sid, s.serial# ;<br /><strong>--2.查出锁定表的session的sid, serial#,os_user_name, machine name, terminal和执行的语句</strong><br /><em><strong><font color="#0000ff">--比上面那段多出sql_text和action</font></strong></em><br />SELECT l.session_id sid, s.serial#, l.locked_mode, l.oracle_username, s.user#,<br />l.os_user_name,s.machine, s.terminal,a.sql_text, a.action<br />FROM v$sqlarea a,v$session s, v$locked_object l<br />WHERE l.session_id = s.sid<br />AND s.prev_sql_addr = a.address<br />ORDER BY sid, s.serial#;<br /><strong>--3.查出锁定表的sid, serial#,os_user_name, machine_name, terminal，锁的type,mode</strong><br />SELECT s.sid, s.serial#, s.username, s.schemaname, s.osuser, s.process, s.machine,<br />s.terminal, s.logon_time, l.type<br />FROM v$session s, v$lock l<br />WHERE s.sid = l.sid<br />AND s.username IS NOT NULL<br />ORDER BY sid;</p>
<p>这个语句将查找到数据库中所有的DML语句产生的锁，还可以发现，<br />任何DML语句其实产生了两个锁，一个是表锁，一个是行锁。<br /><strong>杀锁命令</strong><br /><font color="#0000ff">alter system kill session 'sid,serial#'<br /></font>SELECT /*+ rule */ s.username,<br />decode(l.type,'TM','TABLE LOCK',<br />'TX','ROW LOCK',<br />NULL) LOCK_LEVEL,<br />o.owner,o.object_name,o.object_type,<br />s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser<br />FROM v$session s,v$lock l,dba_objects o<br />WHERE l.sid = s.sid<br />AND l.id1 = o.object_id(+)<br />AND s.username is NOT NULL<br />如果发生了锁等待，我们可能更想知道是谁锁了表而引起谁的等待<br />以下的语句可以查询到谁锁了表，而谁在等待。<br />以上查询结果是一个树状结构，如果有子节点，则表示有等待发生。<br />如果想知道锁用了哪个回滚段，还可以关联到V$rollname，其中xidusn就是回滚段的USN<br />col user_name format a10<br />col owner format a10<br />col object_name format a10<br />col object_type format a10<br />SELECT /*+ rule */ lpad(' ',decode(l.xidusn ,0,3,0))||l.oracle_username User_name,<br />o.owner,o.object_name,o.object_type,s.sid,s.serial#<br />FROM v$locked_object l,dba_objects o,v$session s<br />WHERE l.object_id=o.object_id<br />AND l.session_id=s.sid<br />ORDER BY o.object_id,xidusn DESC</p></div><script type="text/javascript">
if ($ != jQuery) {
	$ = jQuery.noConflict();
}
var isLogined = false;
var cb_blogId = 33324;
var cb_entryId = 1150893;
var cb_blogApp = "swcjd";
var cb_blogUserGuid = "208e3d0b-63cf-dd11-9e4d-001cf0cd104b";
var cb_entryCreatedDate = '2008/4/13 1:19:00';
</script><img src ="http://www.blogjava.net/1504/aggbug/359672.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-09-28 10:58 <a href="http://www.blogjava.net/1504/archive/2011/09/28/359672.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>swing画印章【转】</title><link>http://www.blogjava.net/1504/archive/2011/07/14/354328.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Thu, 14 Jul 2011 07:53:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/07/14/354328.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/354328.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/07/14/354328.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/354328.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/354328.html</trackback:ping><description><![CDATA[<div><a href="/Files/1504/seal.zip"><font class="Apple-style-span" color="#666666" face="monospace"><span class="Apple-style-span" style="font-size: 12px; line-height: normal; white-space: pre; "><br /></span></font>http://www.java3z.com/cwbwebhome/article/article5/51352.html?id=4419<br /><img src="http://www.blogjava.net/images/blogjava_net/1504/seaeww.jpg" border="0" alt="" width="436" height="312" /><br /><br /></a><div><span style="color: #666666; font-family: Tahoma; font-size: 12px; line-height: normal; "><a href="/Files/1504/seal.zip">代码下载<br /></a><pre><br /></pre></span></div><a href="http://www.java3z.com/cwbwebhome/article/article5/51352.html?id=4419">
</a></div><img src ="http://www.blogjava.net/1504/aggbug/354328.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-07-14 15:53 <a href="http://www.blogjava.net/1504/archive/2011/07/14/354328.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Js操作Select大全  【转】</title><link>http://www.blogjava.net/1504/archive/2011/06/20/352667.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Mon, 20 Jun 2011 07:03:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/06/20/352667.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/352667.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/06/20/352667.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/352667.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/352667.html</trackback:ping><description><![CDATA[<div><div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #000000">判断select选项中&nbsp;是否存在Value</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">paraValue</span><span style="color: #000000">"</span><span style="color: #000000">的Item&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />向select选项中&nbsp;加入一个Item&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />从select选项中&nbsp;删除一个Item&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />删除select中选中的项&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />修改select选项中&nbsp;value</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">paraValue</span><span style="color: #000000">"</span><span style="color: #000000">的text为</span><span style="color: #000000">"</span><span style="color: #000000">paraText</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />设置select中text</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">paraText</span><span style="color: #000000">"</span><span style="color: #000000">的第一个Item为选中&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />设置select中value</span><span style="color: #000000">=</span><span style="color: #000000">"</span><span style="color: #000000">paraValue</span><span style="color: #000000">"</span><span style="color: #000000">的Item为选中&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />得到select的当前选中项的value&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />得到select的当前选中项的text&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />得到select的当前选中项的Index&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />清空select的项&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />js&nbsp;代码<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;1.判断select选项中&nbsp;是否存在Value="paraValue"的Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_405_699_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_405_699_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">function</span><span style="color: #000000">&nbsp;jsSelectIsExitItem(objSelect,&nbsp;objItemValue)&nbsp;</span><span id="Codehighlighter1_405_699_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;isExit&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #0000ff">false</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_502_662_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_502_662_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;objSelect.options.length;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)&nbsp;</span><span id="Codehighlighter1_502_662_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_568_648_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_568_648_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(objSelect.options[i].value&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;objItemValue)&nbsp;</span><span id="Codehighlighter1_568_648_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isExit&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #0000ff">true</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;isExit;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;2.向select选项中&nbsp;加入一个Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_812_1124_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_812_1124_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">function</span><span style="color: #000000">&nbsp;jsAddItemToSelect(objSelect,&nbsp;objItemText,&nbsp;objItemValue)&nbsp;</span><span id="Codehighlighter1_812_1124_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">判断是否存在&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_896_953_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_896_953_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(jsSelectIsExitItem(objSelect,&nbsp;objItemValue))&nbsp;</span><span id="Codehighlighter1_896_953_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">该Item的Value值已经存在</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_960_1114_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_960_1114_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span>&nbsp;<span style="color: #0000ff">else</span>&nbsp;<span id="Codehighlighter1_960_1114_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;varItem&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;Option(objItemText,&nbsp;objItemValue);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objSelect.options.add(varItem);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">成功加入</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;3.从select选项中&nbsp;删除一个Item&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_1228_1692_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1228_1692_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">function</span><span style="color: #000000">&nbsp;jsRemoveItemFromSelect(objSelect,&nbsp;objItemValue)&nbsp;</span><span id="Codehighlighter1_1228_1692_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">判断是否存在&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_1312_1620_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1312_1620_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(jsSelectIsExitItem(objSelect,&nbsp;objItemValue))&nbsp;</span><span id="Codehighlighter1_1312_1620_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_1381_1575_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1381_1575_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;objSelect.options.length;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)&nbsp;</span><span id="Codehighlighter1_1381_1575_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_1451_1557_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1451_1557_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(objSelect.options[i].value&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;objItemValue)&nbsp;</span><span id="Codehighlighter1_1451_1557_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objSelect.options.remove(i);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">成功删除</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_1627_1682_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1627_1682_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span>&nbsp;<span style="color: #0000ff">else</span>&nbsp;<span id="Codehighlighter1_1627_1682_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">该select中&nbsp;不存在该项</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;4.删除select中选中的项&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_1780_1999_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_1780_1999_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">function</span><span style="color: #000000">&nbsp;jsRemoveSelectedItemFromSelect(objSelect)&nbsp;</span><span id="Codehighlighter1_1780_1999_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;length&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;objSelect.options.length&nbsp;</span><span style="color: #000000">-</span>&nbsp;<span style="color: #000000">1</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_1877_1993_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1877_1993_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;length;&nbsp;i&nbsp;</span><span style="color: #000000">&gt;=</span>&nbsp;<span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i</span><span style="color: #000000">--</span><span style="color: #000000">)</span><span id="Codehighlighter1_1877_1993_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_1924_1983_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1924_1983_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">(objSelect[i].selected&nbsp;</span><span style="color: #000000">==</span>&nbsp;<span style="color: #0000ff">true</span><span style="color: #000000">)</span><span id="Codehighlighter1_1924_1983_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objSelect.options[i]&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #0000ff">null</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;5.修改select选项中&nbsp;value="paraValue"的text为"paraText"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_2138_2614_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_2138_2614_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">function</span><span style="color: #000000">&nbsp;jsUpdateItemToSelect(objSelect,&nbsp;objItemText,&nbsp;objItemValue)&nbsp;</span><span id="Codehighlighter1_2138_2614_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">判断是否存在&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_2222_2542_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_2222_2542_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(jsSelectIsExitItem(objSelect,&nbsp;objItemValue))&nbsp;</span><span id="Codehighlighter1_2222_2542_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_2291_2497_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_2291_2497_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;objSelect.options.length;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)&nbsp;</span><span id="Codehighlighter1_2291_2497_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_2361_2479_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_2361_2479_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(objSelect.options[i].value&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;objItemValue)&nbsp;</span><span id="Codehighlighter1_2361_2479_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objSelect.options[i].text&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;objItemText;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">成功修改</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_2549_2604_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_2549_2604_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span>&nbsp;<span style="color: #0000ff">else</span>&nbsp;<span id="Codehighlighter1_2549_2604_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">该select中&nbsp;不存在该项</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;6.设置select中text="paraText"的第一个Item为选中&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_2730_3239_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_2730_3239_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">function</span><span style="color: #000000">&nbsp;jsSelectItemByValue(objSelect,&nbsp;objItemText)&nbsp;</span><span id="Codehighlighter1_2730_3239_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">判断是否存在&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;isExit&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #0000ff">false</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_2852_3068_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_2852_3068_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">for</span><span style="color: #000000">&nbsp;(</span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;i&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #000000">0</span><span style="color: #000000">;&nbsp;i&nbsp;</span><span style="color: #000000">&lt;</span><span style="color: #000000">&nbsp;objSelect.options.length;&nbsp;i</span><span style="color: #000000">++</span><span style="color: #000000">)&nbsp;</span><span id="Codehighlighter1_2852_3068_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_2916_3054_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_2916_3054_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(objSelect.options[i].text&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;objItemText)&nbsp;</span><span id="Codehighlighter1_2916_3054_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objSelect.options[i].selected&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #0000ff">true</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isExit&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #0000ff">true</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">break</span><span style="color: #000000">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">Show出结果&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img id="Codehighlighter1_3122_3167_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_3122_3167_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" /></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(isExit)&nbsp;</span><span id="Codehighlighter1_3122_3167_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">成功选中</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img id="Codehighlighter1_3174_3229_Open_Image" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_3174_3229_Closed_Image" style="display: none" alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span>&nbsp;<span style="color: #0000ff">else</span>&nbsp;<span id="Codehighlighter1_3174_3229_Open_Text"><span style="color: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(</span><span style="color: #000000">"</span><span style="color: #000000">该select中&nbsp;不存在该项</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;7.设置select中value="paraValue"的Item为选中&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #000000">document.all.objSelect.value&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;objItemValue;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;8.得到select的当前选中项的value&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;currSelectValue&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;document.all.objSelect.value;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;9.得到select的当前选中项的text&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;currSelectText&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;document.all.objSelect.options[document.all.objSelect.selectedIndex].text;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;10.得到select的当前选中项的Index&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">var</span><span style="color: #000000">&nbsp;currSelectIndex&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;document.all.objSelect.selectedIndex;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;11.清空select的项&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000"><br /><img alt="" src="http://www.cnblogs.com/Images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #000000">document.all.objSelect.options.length&nbsp;</span><span style="color: #000000">=</span>&nbsp;<span style="color: #000000">0</span><span style="color: #000000">; &nbsp;</span></div></div><img src ="http://www.blogjava.net/1504/aggbug/352667.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-06-20 15:03 <a href="http://www.blogjava.net/1504/archive/2011/06/20/352667.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA对数字证书的常用操作【转】</title><link>http://www.blogjava.net/1504/archive/2011/06/20/352666.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Mon, 20 Jun 2011 07:01:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/06/20/352666.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/352666.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/06/20/352666.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/352666.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/352666.html</trackback:ping><description><![CDATA[<div><div><div><span style="font-size: 8pt; ">一：需要包含的包</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import java.security.*;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import java.io.*;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import java.util.*;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import java.security.*;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import java.security.cert.*;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import sun.security.x509.*</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import java.security.cert.Certificate;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; import java.security.cert.CertificateFactory;</span></div><div></div><div><span style="font-size: 8pt; ">二：从文件中读取证书</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; 用keytool将.keystore中的证书写入文件中，然后从该文件中读取证书信息</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; CertificateFactory cf=CertificateFactory.getInstance("X.509");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in=new FileInputStream("out.csr");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; Certificate c=cf.generateCertificate(in);</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; String s=c.toString();</span></div><div><span style="font-size: 8pt; ">三：从密钥库中直接读取证书</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; String pass="123456";</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in=new FileInputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; KeyStore ks=KeyStore.getInstance("JKS");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.load(in,pass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; java.security.cert.Certificate c=ks.getCertificate(alias);//alias为条目的别名</span></div><div></div><div><span style="font-size: 8pt; ">四：JAVA程序中显示证书指定信息</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("输出证书信息:\n"+c.toString());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("版本号:"+t.getVersion());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("序列号:"+t.getSerialNumber().toString(16));</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("主体名："+t.getSubjectDN());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("签发者："+t.getIssuerDN());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("有效期："+t.getNotBefore());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("签名算法："+t.getSigAlgName());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; byte [] sig=t.getSignature();//签名值&nbsp;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; PublicKey pk=t.getPublicKey();</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; byte [] pkenc=pk.getEncoded(); &nbsp;</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("公钥");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; for(int i=0;i&lt;pkenc.length;i++)System.out.print(pkenc[i]+",");</span></div><div></div><div><span style="font-size: 8pt; ">五：JAVA程序列出密钥库所有条目</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; String pass="123456";</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in=new FileInputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; KeyStore ks=KeyStore.getInstance("JKS");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.load(in,pass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; Enumeration e=ks.aliases();</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; while(e.hasMoreElements())</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; java.security.cert.Certificate c=ks.getCertificate((String)e.nextElement());</span></div><div></div><div><span style="font-size: 8pt; ">六：JAVA程序修改密钥库口令</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; String oldpass="123456";</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; String newpass="654321";</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in=new FileInputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; KeyStore ks=KeyStore.getInstance("JKS");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.load(in,oldpass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; in.close();</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileOutputStream output=new FileOutputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.store(output,newpass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; output.close();</span></div><div></div><div><span style="font-size: 8pt; ">七：JAVA程序修改密钥库条目的口令及添加条目</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in=new FileInputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; KeyStore ks=KeyStore.getInstance("JKS");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.load(in,storepass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; Certificate [] cchain=ks.getCertificate(alias);获取别名对应条目的证书链</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; PrivateKey pk=(PrivateKey)ks.getKey(alias,oldkeypass.toCharArray());获取别名对应条目的私钥</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.setKeyEntry(alias,pk,newkeypass.toCharArray(),cchain);向密钥库中添加条目</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; 第一个参数指定所添加条目的别名，假如使用已存在别名将覆盖已存在条目，使用新别名将增加一个新条目，第二个参数为条目的私钥，第三个为设置的新口令，第四个为该私钥的公钥的证书链</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileOutputStream output=new FileOutputStream("another");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.store(output,storepass.toCharArray())将keystore对象内容写入新文件</span></div><div></div><div><span style="font-size: 8pt; ">八：JAVA程序检验别名和删除条目</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in=new FileInputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; KeyStore ks=KeyStore.getInstance("JKS");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.load(in,storepass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.containsAlias("sage");检验条目是否在密钥库中，存在返回true</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.deleteEntry("sage");删除别名对应的条目</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileOutputStream output=new FileOutputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.store(output,storepass.toCharArray())将keystore对象内容写入文件,条目删除成功</span></div><div></div><div><span style="font-size: 8pt; ">九：JAVA程序签发数字证书</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （1）从密钥库中读取CA的证书</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in=new FileInputStream(".keystore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; KeyStore ks=KeyStore.getInstance("JKS");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.load(in,storepass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; java.security.cert.Certificate c1=ks.getCertificate("caroot");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （2）从密钥库中读取CA的私钥</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; PrivateKey caprk=(PrivateKey)ks.getKey(alias,cakeypass.toCharArray());</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （3）从CA的证书中提取签发者的信息</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; byte[] encod1=c1.getEncoded(); &nbsp; &nbsp;提取CA证书的编码</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; X509CertImpl cimp1=new X509CertImpl(encod1); &nbsp;用该编码创建X509CertImpl类型对象</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; X509CertInfo cinfo1=(X509CertInfo)cimp1.get(X509CertImpl.NAME+"."+X509CertImpl.INFO); &nbsp;获取X509CertInfo对象</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; X500Name issuer=(X500Name)cinfo1.get(X509CertInfo.SUBJECT+"."+CertificateIssuerName.DN_NAME); 获取X509Name类型的签发者信息</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （4）获取待签发的证书</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; CertificateFactory cf=CertificateFactory.getInstance("X.509");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in2=new FileInputStream("user.csr");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; java.security.cert.Certificate c2=cf.generateCertificate(in);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （5）从待签发的证书中提取证书信息</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; byte [] encod2=c2.getEncoded();</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; X509CertImpl cimp2=new X509CertImpl(encod2); &nbsp;用该编码创建X509CertImpl类型对象</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; X509CertInfo cinfo2=(X509CertInfo)cimp2.get(X509CertImpl.NAME+"."+X509CertImpl.INFO); &nbsp;获取X509CertInfo对象</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （6）设置新证书有效期</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; Date begindate=new Date(); 获取当前时间</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; Date enddate=new Date(begindate.getTime()+3000*24*60*60*1000L); 有效期为3000天</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; CertificateValidity cv=new CertificateValidity(begindate,enddate); 创建对象</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; cinfo2.set(X509CertInfo.VALIDITY,cv); &nbsp;设置有效期</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （7）设置新证书序列号</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; int sn=(int)(begindate.getTime()/1000); &nbsp; &nbsp;以当前时间为序列号</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; CertificateSerialNumber csn=new CertificateSerialNumber(sn);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; cinfo2.set(X509CertInfo.SERIAL_NUMBER,csn);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （8）设置新证书签发者</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; cinfo2.set(X509CertInfo.ISSUER+"."+CertificateIssuerName.DN_NAME,issuer);应用第三步的结果</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （9）设置新证书签名算法信息</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; AlgorithmId algorithm=new AlgorithmId(AlgorithmId.md5WithRSAEncryption_oid);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; cinfo2.set(CertificateAlgorithmId.NAME+"."+CertificateAlgorithmId.ALGORITHM,algorithm);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （10）创建证书并使用CA的私钥对其签名</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; X509CertImpl newcert=new X509CertImpl(cinfo2);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; newcert.sign(caprk,"MD5WithRSA"); 使用CA私钥对其签名</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （11）将新证书写入密钥库</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.setCertificateEntry("lf_signed",newcert);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileOutputStream out=new FileOutputStream("newstore");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; ks.store(out,"newpass".toCharArray()); &nbsp;这里是写入了新的密钥库，也可以使用第七条来增加条目</span></div><div></div><div><span style="font-size: 8pt; ">十：数字证书的检验</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; （1）验证证书的有效期</span></div><div><span style="font-size: 8pt; ">&nbsp;（a）获取X509Certificate类型对象</span></div><div><span style="font-size: 8pt; ">&nbsp;CertificateFactory cf=CertificateFactory.getInstance("X.509");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; FileInputStream in1=new FileInputStream("aa.crt");</span></div><div><span style="font-size: 8pt; ">&nbsp; java.security.cert.Certificate &nbsp;c1=cf.generateCertificate(in1);</span></div><div><span style="font-size: 8pt; ">&nbsp;X509Certificate t=(X509Certificate)c1;</span></div><div><span style="font-size: 8pt; ">&nbsp; in2.close();</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; （b）获取日期</span></div><div><span style="font-size: 8pt; ">&nbsp;Date TimeNow=new Date();</span></div><div><span style="font-size: 8pt; ">&nbsp;（c）检验有效性</span></div><div><span style="font-size: 8pt; ">&nbsp;try{</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; t.checkValidity(TimeNow);</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println("OK");</span></div><div><span style="font-size: 8pt; ">&nbsp;}catch(CertificateExpiredException e){ &nbsp;//过期</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("Expired");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println(e.getMessage());</span></div><div><span style="font-size: 8pt; ">&nbsp;}catch((CertificateNotYetValidException e){ //尚未生效</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println("Too early");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; System.out.println(e.getMessage());}</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp;（2）验证证书签名的有效性</span></div><div><span style="font-size: 8pt; ">&nbsp;（a）获取CA证书</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CertificateFactory cf=CertificateFactory.getInstance("X.509");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp;FileInputStream in2=new FileInputStream("caroot.crt");</span></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp;java.security.cert.Certificate &nbsp;cac=cf.generateCertificate(in2);</span></div><div><span style="font-size: 8pt; ">&nbsp; in2.close();</span></div><div><span style="font-size: 8pt; ">&nbsp;（c）获取CA的公钥</span></div><div><span style="font-size: 8pt; ">&nbsp; PublicKey pbk=cac.getPublicKey();</span></div><div><span style="font-size: 8pt; ">&nbsp;（b）获取待检验的证书（上步已经获取了，就是C1）</span></div><div><span style="font-size: 8pt; ">&nbsp;（c）检验证书</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;boolean pass=false;</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try{</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; c1.verify(pbk);</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pass=true;</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}catch(Exception e){</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pass=false;</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(e);</span></div><div></div><div><span style="font-size: 8pt; ">&nbsp; }</span></div><div></div><div></div><div></div><div><span style="font-size: 8pt; ">本文来自CSDN博客，转载请标明出处：file:///E:/20.html/JAVA对数字证书的常用操作%20-%20在JAVA的世界中&#8220;乘风破浪&#8221;%20-%20CSDN博客.mht</span></div></div></div><img src ="http://www.blogjava.net/1504/aggbug/352666.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-06-20 15:01 <a href="http://www.blogjava.net/1504/archive/2011/06/20/352666.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>IS08583报文协议包的解析和封装java源代码 【转】</title><link>http://www.blogjava.net/1504/archive/2011/06/20/352665.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Mon, 20 Jun 2011 06:58:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/06/20/352665.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/352665.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/06/20/352665.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/352665.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/352665.html</trackback:ping><description><![CDATA[<div><p><span style="font-size: 8pt; ">前段时间做了一个涉及到IS08583报文协议的项目，自己总结写了这篇附有java源代码的文章，希望能给大家提供一些帮助，本文分四个部分介绍IS08583报文协议包的处理及如何解析请求包及怎样封装返回包，</span></p> <p><strong style="font-size: 8pt; ">一：IS08583包介绍：</strong></p> <p><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp; ISO8583包（简称8583包）是一个国际标准的包格式，最多由128个字段域组成，每个域都有统一的规定，并有定长与变长之分。</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp;  &nbsp;8583包前面一段为位图，用来确定包的字段域组成情况。其中位图是8583包的灵魂，它是打包解包确定字段域的关键，  而了解每个字段域的属性则是填写数据的基础。&nbsp;&nbsp;&nbsp;</span></p> <p><span style="font-size: 8pt; ">&nbsp;1：位图说明：</span></p> <p><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp; 位置：在8583包的第1 位</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp; 格式：定长 &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp; 类型：B16（二进制16位，16*8=128bit）  &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp; 描述：&nbsp;&nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;  如将位图的第一位设为'1'，表示使用扩展位图（128个域），否则表示只使用基本位图（64个域）。&nbsp;&nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如使用某数据域，应在位图中将相应的位设位'1'，如使用41域，需将位图的41位设为'1'。&nbsp;&nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;  选用条件：如使用65到128域，需设位图域第一位为'1'&nbsp;&nbsp;</span><br /><span style="font-size: 8pt; ">2：域的定义： &nbsp;</span><br /><span style="font-size: 8pt; ">typedef struct ISO8583 &nbsp;</span><br /><span style="font-size: 8pt; ">{  &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; int bit_flag;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*域数据类型0 -- string, 1 -- int, 2 -- binary*/  &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; char *data_name;&nbsp; /*域名*/ &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; int length;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*数据域长度*/  &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; int length_in_byte;/*实际长度（如果是变长）*/ &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; int variable_flag;&nbsp;  &nbsp;/*是否变长标志0：否 2：2位变长, 3：3位变长*/ &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; int datatyp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*0 -- string, 1 --  int, 2 -- binary*/ &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; char *data;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;/*存放具体值*/ &nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp; &nbsp; int  attribute;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*保留*/ &nbsp;</span><br /><span style="font-size: 8pt; ">} ISO8583;</span><br /><br /><strong style="font-size: 8pt; ">二：定义BitMap类</strong></p> <p><span style="font-size: 8pt; ">类说明：根据ISO8583&nbsp;包的域定义，定义BitMap类存储每个域的信息。例如：</span></p> <p><span style="font-size: 8pt; ">package com.lottery.pos.model;</span></p> <p><span style="font-size: 8pt; ">public&nbsp; class BitMap {</span><br /><span style="font-size: 8pt; ">&nbsp;private int bit;&nbsp;//位</span><br /><span style="font-size: 8pt; ">&nbsp;private int bittype;  //数据类型 1 ascii 2 binary</span><br /><span style="font-size: 8pt; ">&nbsp;private int variable;&nbsp; //是否变长0 不是 2 两位变长 3  三位变长</span><br /><span style="font-size: 8pt; ">&nbsp;private int len;&nbsp;//数据长度</span><br /><span style="font-size: 8pt; ">&nbsp;private byte[] dat;&nbsp;//数据</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;public  int getBit() {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return bit;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public void setBit(int bit)  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;this.bit = bit;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public int getBittype() {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  bittype;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public void setBittype(int bittype) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;this.bittype =  bittype;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public int getVariable() {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  variable;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public void setVariable(int variable) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;this.variable =  variable;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public byte[] getDat() {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return dat;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public  void setDat(byte[] dat) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;this.dat = dat;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public int getLen()  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return len;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;public void setLen(int len) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;this.len =  len;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span></p> <p><br /><span style="font-size: 8pt; ">}</span></p> <p>&nbsp;</p> <p><strong style="font-size: 8pt; ">三：定义PortConfig类</strong></p> <p><span style="font-size: 8pt; ">类说明：定义配置信息类。根据此类解析和封装数据。例如：</span></p> <p><span style="font-size: 8pt; ">package com.lottery.pos.model;</span></p> <p><span style="font-size: 8pt; ">public class PortConfig {</span><br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 存放所有接口的配置信息</span><br /><span style="font-size: 8pt; ">&nbsp; * [][0] bit&nbsp;&nbsp;&nbsp;&nbsp;  位:在Map中的位</span><br /><span style="font-size: 8pt; ">&nbsp; * [][1] type&nbsp;&nbsp; 类型:1 ascii 2 binary</span><br /><span style="font-size: 8pt; ">&nbsp; * [][2] len&nbsp;&nbsp;&nbsp;  长度:(对定长有效)</span><br /><span style="font-size: 8pt; ">&nbsp; * [][3] varLen 变长:0非变长 2位变长 3位变长</span><br /><span style="font-size: 8pt; ">&nbsp;  */</span><br /><span style="font-size: 8pt; ">&nbsp;//&nbsp;定义一个二位数组存放配置信息。</span><br /><span style="font-size: 8pt; ">&nbsp;public static final&nbsp; int[][] config= {  </span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{11,1,6,0}, </span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{12,1,6,0},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{13,1,4,0},  </span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{32,1,11,0},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{37,1,12,0},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{39,1,2,0},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{40,2,50,2},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{41,1,8,0},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{48,1,52,3},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{120,2,128,3},</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;};</span></p> <p><span style="font-size: 8pt; ">｝</span></p> <p><strong style="font-size: 8pt; ">四：定义BitMapiso类</strong></p> <p><span style="font-size: 8pt; ">类说明：此类提供解析请求包和封装信息包两个方法，例如：</span></p> <p><span style="font-size: 8pt; ">package com.lottery.pos.utils;</span></p> <p><span style="font-size: 8pt; ">import java.util.ArrayList;</span><br /><span style="font-size: 8pt; ">import java.util.List;</span></p> <p><span style="font-size: 8pt; ">import com.lottery.pos.model.BitMap;</span></p> <p><span style="font-size: 8pt; ">public class BitMapiso {</span></p> <p><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 解析请求包</span><br /><span style="font-size: 8pt; ">&nbsp; * @param body</span><br /><span style="font-size: 8pt; ">&nbsp; * @param config</span><br /><span style="font-size: 8pt; ">&nbsp; * @return  List</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;@SuppressWarnings("unchecked")</span><br /><span style="font-size: 8pt; ">&nbsp;public static List  unpackRequest(byte[] body, int[][] config) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;List outList = new  ArrayList();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// 取得除信息类型以外的包信息。也就是取得位图的初始位置。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte[] realbody = new  byte[body.length - 4];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;System.arraycopy(body, 4, realbody, 0,  realbody.length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// 取得位图</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte[] map = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte[] map8 = new  byte[8];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;System.arraycopy(realbody, 0, map8, 0, 8);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;boolean[] bmap8 =  LoUtils.getBinaryFromByte(map8);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;if (bmap8[1]) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;//  如果第一位为1，则是可扩展位图，设为16字节长度。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;map = new  byte[16];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;System.arraycopy(realbody, 0, map, 0, 16);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;} else  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;map = map8;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;boolean[] bmap =  LoUtils.getBinaryFromByte(map);</span></p> <p><span style="font-size: 8pt; ">&nbsp;&nbsp;int tmplen = map.length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 2; i &lt; bmap.length; i++)  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;if (bmap[i]) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;//BitMap bitMap = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;//  寻找位图中的1对应的数据</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;int bit=-1;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;for (int j = 0; j &lt; config.length;  j++) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (config[j][0] == i)  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bit=j;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;BitMap outBitMap =  new  BitMap();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;outBitMap.setBit(i);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;outBitMap.setBittype(config[bit][1]);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;//len对变长是无用的。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;outBitMap.setLen(config[bit][2]);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;outBitMap.setVariable(config[bit][3]);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;byte[]  nextData = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;if (config[bit][3] &gt; 0)  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//取出变长部分的值。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int varLen = config[bit][3];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if  (config[bit][1] == 2) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;varLen = varLen - 1;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte[]  varValue = new byte[varLen];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.arraycopy(realbody, tmplen,  varValue, 0,&nbsp;varValue.length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int datLen = 0;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if  (config[bit][1] == 2) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;datLen = LoUtils.bcdToint(varValue);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  else {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;datLen = byteToInt(varValue);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></p> <p><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmplen += varLen;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 取出变长部分后带的值。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextData = new  byte[datLen];</span></p> <p><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.arraycopy(realbody, tmplen, nextData,  0,nextData.length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmplen += nextData.length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;} else  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextData = new  byte[config[bit][2]];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.arraycopy(realbody, tmplen, nextData,  0,nextData.length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tmplen +=  config[bit][2];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;outBitMap.setDat(nextData);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;outList.add(outBitMap);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span></p> <p><span style="font-size: 8pt; ">&nbsp;&nbsp;return outList;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span></p> <p>&nbsp;</p> <p><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 打包响应包,不包括消息类型</span><br /><span style="font-size: 8pt; ">&nbsp; * @param list</span><br /><span style="font-size: 8pt; ">&nbsp; * @return byte[]</span><br /><span style="font-size: 8pt; ">&nbsp;  */</span><br /><span style="font-size: 8pt; ">&nbsp;@SuppressWarnings("unchecked")</span><br /><span style="font-size: 8pt; ">&nbsp;public static byte[] PackResponse(List  list) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;int len = 16;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0; i &lt; list.size(); i++)  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;BitMap bitMap = (BitMap) list.get(i);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// 计算请求包总长度</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;if  (bitMap.getBittype() == 2) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;if (bitMap.getVariable() &gt; 0)  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;len += bitMap.getVariable() - 1 + bitMap.getDat().length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;}  else {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;len += bitMap.getVariable() +  bitMap.getDat().length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;} else {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;len +=  bitMap.getVariable() + bitMap.getDat().length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte[] body =  new byte[len];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// 位图</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;boolean[] bbitMap = new  boolean[129];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;bbitMap[1] = true;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;int temp = (bbitMap.length - 1) /  8;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int j = 0; j &lt; list.size(); j++) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;BitMap bitMap =  (BitMap) list.get(j);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;bbitMap[bitMap.getBit()] = true;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;byte[] bitmap  = LoUtils.getByteFromBinary(bbitMap);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;System.arraycopy(bitmap, 0, body, 0,  bitmap.length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// 数据</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;if (bitMap.getVariable() &gt; 0) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;//  数据是可变长的:拼变长的值</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;byte[] varValue = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;if (bitMap.getBittype() ==  2) {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;varValue = LoUtils.StrToBCDBytes(String.format("%0"+  bitMap.getVariable() + "d",bitMap.getDat().length));</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;} else  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;varValue = String.format("%0" + bitMap.getVariable() +  "d",bitMap.getDat().length).getBytes();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;System.arraycopy(varValue,  0, body, temp, varValue.length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;temp += varValue.length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;//  拼变长部分后所带的数的值。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;System.arraycopy(bitMap.getDat(), 0, body, temp,  bitMap.getDat().length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;temp += bitMap.getDat().length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;} else  {</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;// 数据是固定长度的。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;byte dat[] =new byte[bitMap.getLen()];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;if  (bitMap.getDat().length!=bitMap.getLen()){&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.arraycopy(bitMap.getDat(),  0, dat, 0,  bitMap.getLen());</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;}else{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dat=bitMap.getDat();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;System.arraycopy(dat,  0, body, temp, dat.length);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;temp +=  bitMap.getDat().length;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return body;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span></p> <p>&nbsp;</p> <p><span style="font-size: 8pt; ">｝</span></p> <p>&nbsp;</p> <p>&nbsp;</p> <p><span style="font-size: 8pt; ">package com.lottery.utils;</span></p> <p><span style="font-size: 8pt; ">import java.io.BufferedInputStream;</span><br /><span style="font-size: 8pt; ">import  java.io.ByteArrayOutputStream;</span><br /><span style="font-size: 8pt; ">import java.io.IOException;</span></p> <p><span style="font-size: 8pt; ">import javax.servlet.http.HttpServletRequest;</span></p> <p><span style="font-size: 8pt; ">import sun.misc.BASE64Decoder;</span><br /><span style="font-size: 8pt; ">import sun.misc.BASE64Encoder;</span></p> <p><span style="font-size: 8pt; ">/**</span><br /><span style="font-size: 8pt; ">&nbsp;* 编码与数据类型类</span><br /><span style="font-size: 8pt; ">&nbsp;* </span><br /><span style="font-size: 8pt; ">&nbsp;* @author LLH</span><br /><span style="font-size: 8pt; ">&nbsp;*/</span><br /><span style="font-size: 8pt; ">public class  LoUtils</span><br /><span style="font-size: 8pt; ">{</span><br /><span style="font-size: 8pt; ">&nbsp;private static BASE64Encoder&nbsp;encoder&nbsp;= new BASE64Encoder  ();</span><br /><span style="font-size: 8pt; ">&nbsp;private static BASE64Decoder&nbsp;decoder&nbsp;= new BASE64Decoder  ();</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * BASE64 编码</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param s</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp;  */</span><br /><span style="font-size: 8pt; ">&nbsp;public static String encodeBufferBase64(byte [] buff)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  buff == null ? null : encoder.encode (buff);</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; *  BASE64解码</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param s</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static byte  [] decodeBufferBase64(String s)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;try</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;return s == null ?  null : decoder.decodeBuffer (s);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}catch (IOException  e)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;e.printStackTrace ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  null;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * BASE64 字节数组编码</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param s</span><br /><span style="font-size: 8pt; ">&nbsp; *  @return String</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static String encodeBase64(byte []  s)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;if(s == null)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;return null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String res = new  BASE64Encoder ().encode (s);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;res = res.replace ("\n","");</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;res =  res.replace ("\r","");</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return res;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * BASE64解码</span><br /><span style="font-size: 8pt; ">&nbsp;  * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param s</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static byte []  decodeBase64(byte [] buff)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;if(buff == null)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;return  null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;BASE64Decoder decoder = new BASE64Decoder  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;try</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;byte [] b = decoder.decodeBuffer (new String  (buff));</span><br />&nbsp;&nbsp;&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;return b;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}catch (Exception e)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;return  null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 将reauest里的数据包转成字符串</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param  request</span><br /><span style="font-size: 8pt; ">&nbsp; * @return String</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static String  getRequestBodyTxt(HttpServletRequest request)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;//  接收手机传过来的参数</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;BufferedInputStream bufferedInputStream = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;//  此类实现了一个输出流，其中的数据被写入一个字节数组</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;ByteArrayOutputStream bytesOutputStream =  null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String body = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;try</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br />&nbsp;&nbsp;&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;//  BufferedInputStream 输入流</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;bufferedInputStream = new BufferedInputStream  (</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;request.getInputStream ());</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;bytesOutputStream = new  ByteArrayOutputStream ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// 写入数据</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;int ch;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;while ((ch =  bufferedInputStream.read ()) != -1)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bytesOutputStream.write  (ch);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// 转换为String类型</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;body = new String  (bytesOutputStream.toByteArray (),"UTF-8");</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}catch (Exception  ex)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;ex.printStackTrace ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;finally</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;//  关闭此输入流并释放与该流关联的所有系统资源。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;try</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bytesOutputStream.flush  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bytesOutputStream.close ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bufferedInputStream.close  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}catch (IOException e)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return body;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; *  将reauest里的数据包转成字节数组</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param request</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp;  */</span><br /><span style="font-size: 8pt; ">&nbsp;public static byte [] getRequestBodyByte(HttpServletRequest  request)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// 接收手机传过来的参数</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;BufferedInputStream bufferedInputStream =  null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// 此类实现了一个输出流，其中的数据被写入一个字节数组</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;ByteArrayOutputStream  bytesOutputStream = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte [] body = null;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;try</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;//  BufferedInputStream 输入流</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;bufferedInputStream = new BufferedInputStream  (</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;request.getInputStream ());</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;bytesOutputStream = new  ByteArrayOutputStream ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// 写入数据</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;int ch;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;while ((ch =  bufferedInputStream.read ()) != -1)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bytesOutputStream.write  (ch);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// 转换为String类型</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;body = bytesOutputStream.toByteArray  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}catch (Exception ex)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;ex.printStackTrace  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;finally</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;//  关闭此输入流并释放与该流关联的所有系统资源。</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;try</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bytesOutputStream.flush  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bytesOutputStream.close ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;bufferedInputStream.close  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}catch (IOException e)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return body;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;public static String  getEigthBitsStringFromByte(int b)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// if this is a positive number its  bits number will be less</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// than 8</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// so we have to fill it to be a 8  digit binary string</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// b=b+100000000(2^8=256) then only get the lower 8  digit</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;b |= 256; // mark the 9th digit as 1 to make sure the string</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;//  has at</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// least 8 digits</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String str = Integer.toBinaryString  (b);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;int len = str.length ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return str.substring (len -  8,len);</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;public static byte getByteFromEigthBitsString(String  str)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// if(str.length()!=8)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// throw new Exception("It's not a 8  length string");</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte b;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;// check if it's a minus  number</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;if(str.substring (0,1).equals ("1"))</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// get lower 7  digits original code</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;str = "0" + str.substring (1);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;b = Byte.valueOf  (str,2);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;// then recover the 8th digit as 1 equal to plus</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;//  1000000</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;b |= 128;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;else</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;b = Byte.valueOf  (str,2);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return b;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; *  将一个16字节数组转成128二进制数组</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param b</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public  static boolean [] getBinaryFromByte(byte [] b)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;boolean [] binary =  new boolean [b.length * 8 + 1];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String strsum = "";</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0;i  &lt; b.length;i++ )</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;strsum += getEigthBitsStringFromByte (b  [i]);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0;i &lt; strsum.length ();i++  )</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;if(strsum.substring (i,i + 1).equalsIgnoreCase  ("1"))</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;binary [i + 1] =  true;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;else</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;binary [i + 1] =  false;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return binary;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; *  将一个128二进制数组转成16字节数组</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param binary</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp;  */</span><br /><span style="font-size: 8pt; ">&nbsp;public static byte [] getByteFromBinary(boolean []  binary)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br />&nbsp;&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;&nbsp;int num = (binary.length - 1) /  8;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;if((binary.length - 1) % 8 != 0)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;num = num +  1;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte [] b = new byte [num];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String s = "";</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i =  1;i &lt; binary.length;i++ )</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;if(binary [i])</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;s +=  "1";</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;else</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;s += "0";</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String  tmpstr;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;int j = 0;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0;i &lt; s.length ();i = i +  8)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;tmpstr = s.substring (i,i + 8);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;b [j] =  getByteFromEigthBitsString (tmpstr);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;j = j + 1;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  b;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 将一个byte位图转成字符串</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param b</span><br /><span style="font-size: 8pt; ">&nbsp; *  @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static String getStrFromBitMap(byte []  b)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String strsum = "";</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0;i &lt; b.length;i++  )</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;strsum += getEigthBitsStringFromByte (b [i]);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  strsum;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * bytes转换成十六进制字符串</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param b</span><br /><span style="font-size: 8pt; ">&nbsp; *  @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static String byte2HexStr(byte []  b)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String hs = "";</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;String stmp = "";</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int n = 0;n &lt;  b.length;n++ )</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;stmp = (Integer.toHexString (b [n] &amp;  0XFF));</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;if(stmp.length () == 1)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;hs = hs + "0" +  stmp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;else</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;hs = hs + stmp;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return hs.toUpperCase  ();</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;private static byte uniteBytes(String src0, String  src1)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte b0 = Byte.decode ("0x" + src0).byteValue ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;b0 =  (byte) (b0 &lt;&lt; 4);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte b1 = Byte.decode ("0x" + src1).byteValue  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte ret = (byte) (b0 | b1);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return ret;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; *  十六进制字符串转换成bytes</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param src</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public  static byte [] hexStr2Bytes(String src)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;int m = 0, n = 0;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;int l  = src.length () / 2;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;byte [] ret = new byte [l];</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0;i &lt;  l;i++ )</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;m = i * 2 + 1;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;n = m + 1;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;ret [i] = uniteBytes  (src.substring (i * 2,m),</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;&nbsp;src.substring (m,n));</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  ret;</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 将String转成BCD码</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param s</span><br /><span style="font-size: 8pt; ">&nbsp; *  @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static byte [] StrToBCDBytes(String  s)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br />&nbsp;&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;&nbsp;if(s.length () % 2 != 0)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;s = "0" +  s;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;ByteArrayOutputStream baos = new ByteArrayOutputStream  ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;char [] cs = s.toCharArray ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0;i &lt; cs.length;i  += 2)</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;int high = cs [i] - 48;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;int low = cs [i + 1] -  48;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;baos.write (high &lt;&lt; 4 | low);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return  baos.toByteArray ();</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 将BCD码转成int</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param  b</span><br /><span style="font-size: 8pt; ">&nbsp; * @return</span><br /><span style="font-size: 8pt; ">&nbsp; */</span><br /><span style="font-size: 8pt; ">&nbsp;public static int bcdToint(byte []  b)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;StringBuffer sb = new StringBuffer ();</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;for (int i = 0;i &lt;  b.length;i++ )</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;{</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;int h = ((b [i] &amp; 0xff) &gt;&gt; 4) +  48;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;sb.append ((char) h);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;int l = (b [i] &amp; 0x0f) +  48;</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;&nbsp;sb.append ((char) l);</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;}</span><br /><span style="font-size: 8pt; ">&nbsp;&nbsp;return Integer.parseInt (sb.toString  ());</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br />&nbsp;<br /><span style="font-size: 8pt; ">&nbsp;/**</span><br /><span style="font-size: 8pt; ">&nbsp; * 输出调试信息</span><br /><span style="font-size: 8pt; ">&nbsp; * </span><br /><span style="font-size: 8pt; ">&nbsp; * @param str</span><br /><span style="font-size: 8pt; ">&nbsp;  */</span><br /><span style="font-size: 8pt; ">&nbsp;public static void trace(String str)</span><br /><span style="font-size: 8pt; ">&nbsp;{</span><br /><span style="font-size: 8pt; ">//&nbsp;&nbsp;System.out.println  ("["</span><br /><span style="font-size: 8pt; ">//&nbsp;&nbsp;&nbsp;+ (new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.S")).format (new Date  ())</span><br /><span style="font-size: 8pt; ">//&nbsp;&nbsp;&nbsp;+ "]&gt;" + str);</span><br /><span style="font-size: 8pt; ">&nbsp;}</span><br /><span style="font-size: 8pt; ">}</span><br /></p> <p>&nbsp;</p> <p>&nbsp;</p> <p><span style="font-size: 8pt; ">源代码测试没有问题。</span><br /></p></div><img src ="http://www.blogjava.net/1504/aggbug/352665.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-06-20 14:58 <a href="http://www.blogjava.net/1504/archive/2011/06/20/352665.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>理解并解决GBK转UTF-8奇数中文乱码【转】</title><link>http://www.blogjava.net/1504/archive/2011/06/20/352664.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Mon, 20 Jun 2011 06:56:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/06/20/352664.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/352664.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/06/20/352664.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/352664.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/352664.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: http://www.iteye.com/topic/1097560最近在做一个反馈功能，把数据反馈到对方公司网站，我公司是GBK编码，对方公司是UTF-8编码。因此，我需要将GBK编码数据转换成UTF-8编码数据，这样对方网站才不会乱码。最简单的方法是将HttpClient的ContentCharset设置为utf-8；如果ContentCharset是gbk并且又不想设置为utf-8，那么就需...&nbsp;&nbsp;<a href='http://www.blogjava.net/1504/archive/2011/06/20/352664.html'>阅读全文</a><img src ="http://www.blogjava.net/1504/aggbug/352664.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-06-20 14:56 <a href="http://www.blogjava.net/1504/archive/2011/06/20/352664.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>导入android源码有错，R.java文件不能自动生成解决方法[转]</title><link>http://www.blogjava.net/1504/archive/2011/06/15/352382.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Wed, 15 Jun 2011 13:11:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/06/15/352382.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/352382.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/06/15/352382.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/352382.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/352382.html</trackback:ping><description><![CDATA[<div><a href="http://www.iteye.com/topic/975125">http://www.iteye.com/topic/975125<br /><span class="Apple-style-span" style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; color: #000000; -webkit-text-decorations-in-effect: none; "><table id="forum_main" cellspacing="1" style="width: 946px; background-color: #ffffff; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-color: #006699; border-right-color: #006699; border-bottom-color: #006699; border-left-color: #006699; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-collapse: separate; "><tbody id="posts"><tr id="1998431"><td class="postcontent" style="font-size: 1em; vertical-align: top; width: 798px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: #efefef; "><div class="postactions" style="border-bottom-style: solid; border-bottom-width: 1px; border-top-color: gray; border-right-color: gray; border-bottom-color: gray; border-left-color: gray; padding-top: 3px; padding-right: 20px; padding-bottom: 25px; padding-left: 10px; "><div class="description" style="color: #006699; float: left; width: 430px; height: 18px; overflow-x: hidden; overflow-y: hidden; ">发表时间：2011-03-25&nbsp;&nbsp; 最后修改：2011-03-25</div><div class="links" style="width: 300px; text-align: right; float: right; "><a href="http://www.iteye.com/forums/48/topics/975125/posts/1998431/quote" class="quote" style="color: #006699; text-decoration: underline; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 20px; background-image: url(http://www.iteye.com/images/icon_quote.gif); background-repeat: no-repeat no-repeat; ">引用</a>&nbsp;<a href="http://app.iteye.com/links?user_favorite%5Btitle%5D=%E5%AF%BC%E5%85%A5android%E6%BA%90%E7%A0%81%E6%9C%89%E9%94%99%EF%BC%8CR.java%E6%96%87%E4%BB%B6%E4%B8%8D%E8%83%BD%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95&amp;user_favorite%5Burl%5D=http%3A%2F%2Fwww.iteye.com%2Ftopic%2F975125" target="_blank" class="favorite" style="color: #006699; text-decoration: underline; padding-top: 0px; padding-right: 5px; padding-bottom: 0px; padding-left: 20px; background-image: url(http://www.iteye.com/images/icon_favorite.gif); background-repeat: no-repeat no-repeat; ">收藏</a></div></div><div class="postbody clearfix" style="display: block; padding-top: 20px; padding-right: 0px; padding-bottom: 1px; padding-left: 0px; font-family: Tahoma; min-height: 120px; width: 790px; "><div id="related_topics" style="float: right; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 5px; background-color: #fdfbdb; width: 200px; overflow-x: hidden; overflow-y: hidden; cursor: move; position: relative; ">相关文章:&nbsp;<span class="close" style="margin-left: 125px; "><a href="http://www.iteye.com/topic/975125#" title="关闭" style="color: #006699; text-decoration: none; background-image: url(http://www.iteye.com/images/icon_close.jpg); padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; background-position: 50% 50%; background-repeat: no-repeat no-repeat; ">&nbsp;</a></span><ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: square; list-style-position: initial; list-style-image: initial; "><a href="http://www.iteye.com/topic/619420" title="搭建Android开发环境" target="_blank" style="color: #006699; text-decoration: underline; ">搭建Android开发环境</a></li><li style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: square; list-style-position: initial; list-style-image: initial; "><a href="http://www.iteye.com/topic/508447" title="JavaEye Android 客户端开源啦" target="_blank" style="color: #006699; text-decoration: underline; ">JavaEye Android 客户端开源啦</a></li><li style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: square; list-style-position: initial; list-style-image: initial; "><a href="http://www.iteye.com/topic/411198" title="把Android源代码加入SDK" target="_blank" style="color: #006699; text-decoration: underline; ">把Android源代码加入SDK</a></li></ul><br /><span>推荐群组:&nbsp;<a href="http://android.group.iteye.com/" target="_blank" style="color: #006699; text-decoration: underline; ">Android</a></span>&nbsp;<br /><a href="http://www.iteye.com/wiki/topic/975125" target="_blank" style="color: #006699; text-decoration: underline; ">更多相关推荐</a></div>&nbsp;&nbsp; 最近几天学习android ，学习时候难免要导入一些示例，目的为了更加了解android各种API用法，顺便也可以学习下别人代码的写法。可是导入android源码后，基本都有错误，R.java也不会自动生成，因为是第一次导入工程，工程有错R.java就不会自动生成了，工程有错误，当然模拟器就不能启动，也就看不到效果。随后网上找各种解决方法，网上解决方法主要有这几种&nbsp;<br />&nbsp;&nbsp;<br />1、选择菜单&nbsp; Project &gt;&gt; Clean ，前提是勾选上 Bulid Automatically(自动构建部署) ， 点Clean后会重新构建项目，因为一般情况下，R.java文件在这个时候会重新更新生成一边，如果工程有错，就不会自动生成。&nbsp;<br />2、选择工程，右键 Android Tools &gt;&gt; Fix Project Properties 这个操作有时候可以修正一些错误，但我的不行。&nbsp;<br />3、还有的说法是重新建一个空的工程，然后把这里面的代码，资源文件按照对应的包路径什么的拷进去，然后重新生成一边，这种方法，也想当于是第一种方法，都是重新构建部暑，性质一样的。&nbsp;<br /><br />&nbsp;&nbsp; 以上几种方法都试了，R.java依旧没出现，整个工程还是一大堆错误。随便点了一个有错误的布局XML文件，看到这样一个错误代码android:layout_height="match_parent" ， 之前我都用1.5/1.6/2.1 版本的SDK layout_height里面没有看到match_parent这个属性，然后问群一个兄弟说这个属性是2.X版本的，想了下，是不是因为工程的SDK版本和eclipse默认的SDK版本问题呢，于是选择工程，右键 Properties &gt;&gt; Android 然后看到右边的一块 Target Name， 我的是选中 Android 1.5，然后换了一个 2.1 的 ,点击Appply ,工程自动构建，看到错误少了一些，换到2.2,重新构建，错误没了，久未解决的问题解决了，R.java也出来了，一个字高兴啊，启动模拟器一切正常。&nbsp;<br /><br />&nbsp; 总结下当导入其它源码时候，首先要保证源码的SDK版本和你eclipse默认版本是否一致。&nbsp;<br />查看源码版本办法：打开default.properties 文件，看target=android-7 这后面这个数是多少。&nbsp;<br />版本对应关系：target=android-3 &lt;---&gt; android 1.5&nbsp; ,target=android-4 &lt;---&gt; android 1.6 ,&nbsp;<br />target=android-7 &lt;---&gt; android 2.1&nbsp; ,target=android-8 &lt;---&gt; android 2.2 其它的自己测试下。&nbsp;</div></td></tr></tbody></table></span><br /></a></div><img src ="http://www.blogjava.net/1504/aggbug/352382.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-06-15 21:11 <a href="http://www.blogjava.net/1504/archive/2011/06/15/352382.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于oracle树结构查询 展示 分组，查找父节点，查找子节点问题</title><link>http://www.blogjava.net/1504/archive/2011/03/19/346578.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Fri, 18 Mar 2011 16:43:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2011/03/19/346578.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/346578.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2011/03/19/346578.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/346578.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/346578.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: oracle 2010-09-21 11:32:18 阅读132 评论0 &nbsp;&nbsp;字号：大中小&nbsp;订阅 　Oracle 实在太强了，本篇文章详细介绍了Oracle的递归查询语法，利用此语法，可以方便地实现递归的双向查询： 　　--Tirle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Recursion query f...&nbsp;&nbsp;<a href='http://www.blogjava.net/1504/archive/2011/03/19/346578.html'>阅读全文</a><img src ="http://www.blogjava.net/1504/aggbug/346578.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2011-03-19 00:43 <a href="http://www.blogjava.net/1504/archive/2011/03/19/346578.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>360木马查杀后，竟然发现桌面应用程序的快捷方式全部失效补救办法</title><link>http://www.blogjava.net/1504/archive/2010/12/08/340088.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Wed, 08 Dec 2010 11:41:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2010/12/08/340088.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/340088.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2010/12/08/340088.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/340088.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/340088.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt; "></span><span style="font-size: 36pt; "><span style="font-size: 10pt; "></span></span><span style="font-family: 新宋体; "><span style="font-size: 36pt; "><span style="font-size: 10pt; "></span></span></span><span style="font-size: 10pt; "><span style="font-family: 新宋体; "><span style="font-size: 36pt; "><span style="font-size: 10pt; "><span style="font-size: 14pt; "><strong></strong></span></span></span></span></span><span style="font-size: 8pt; "><span style="font-size: 10pt; "><span style="font-family: 新宋体; "><span style="font-size: 36pt; "><span style="font-size: 10pt; "><span style="font-size: 14pt; "><strong>来自：http://hi.baidu.com/%C3%D7%CB%AE%BA%FA%D3%E0/blog/item/08a498d28f23890c3af3cff6.html</strong>
<div>
<table style="width: 100%; table-layout: fixed; ">
    <tbody>
        <tr>
            <td>
            <div id="blog_text" class="cnt">
            <p><font color="#3d85c6"><strong>今天朋友用360木马查杀后，竟然发现桌面应用程序的快捷方式全部失效，打开程序只能到应用程序安装目录下&#8230;&#8230;</strong></font></p>
            <p><font color="#3d85c6"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            在询问了具体情况之后，咱就到网上搜索解决方案，没想到竟然一下子被咱找到了，刚开始咱还不敢贸然行动，但是在自己使用各种其他方法无效的情况之下，只能活马当死马医了，照着下面的方法一试，竟然马上奏效，故粘贴出来供分享&#8230;&#8230;</strong></font></p>
            <p><font color="#3d85c6"><strong>将下面的字符粘贴到记事本，保存后缀为reg的文件，比如5566.reg，然后双击运行，其中可能弹出其它窗口，但是可以选择确定，然后，应该马上恢复&#8230;&#8230;</strong></font></p>
            <p><font color="#3d85c6"><strong>----------------------------------------------------------------------</strong></font></p>
            <p>&nbsp;</p>
            <p><strong>Windows Registry Editor Version 5.00</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\.lnk]</strong></p>
            <p><strong>@="lnkfile"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\.lnk\ShellEx]</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\.lnk\ShellEx\{000214EE-0000-0000-C000-000000000046}]</strong></p>
            <p><strong>@="{00021401-0000-0000-C000-000000000046}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\.lnk\ShellEx\{000214F9-0000-0000-C000-000000000046}]</strong></p>
            <p><strong>@="{00021401-0000-0000-C000-000000000046}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\.lnk\ShellEx\{00021500-0000-0000-C000-000000000046}]</strong></p>
            <p><strong>@="{00021401-0000-0000-C000-000000000046}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\.lnk\ShellEx\{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}]</strong></p>
            <p><strong>@="{00021401-0000-0000-C000-000000000046}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\.lnk\ShellNew]</strong></p>
            <p><strong>"Command"="rundll32.exe appwiz.cpl,NewLinkHere %1"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile]</strong></p>
            <p><strong>@="快捷方式"</strong></p>
            <p><strong>"EditFlags"=dword:00000001</strong></p>
            <p><strong>"IsShortcut"=""</strong></p>
            <p><strong>"NeverShowExt"=""</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\CLSID]</strong></p>
            <p><strong>@="{00021401-0000-0000-C000-000000000046}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex]</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex\ContextMenuHandlers]</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex\ContextMenuHandlers\Offline Files]</strong></p>
            <p><strong>@="{750fdf0e-2a26-11d1-a3ea-080036587f03}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex\ContextMenuHandlers\{00021401-0000-0000-C000-000000000046}]</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex\DropHandler]</strong></p>
            <p><strong>@="{00021401-0000-0000-C000-000000000046}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex\IconHandler]</strong></p>
            <p><strong>@="{00021401-0000-0000-C000-000000000046}"</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex\PropertySheetHandlers]</strong></p>
            <p><strong>[HKEY_CLASSES_ROOT\lnkfile\shellex\PropertySheetHandlers\ShimLayer Property
            Page]</strong></p>
            <p><strong>@="{513D916F-2A8E-4F51-AEAB-0CBC76FB1AF8}"</strong></p>
            </div>
            </td>
        </tr>
    </tbody>
</table>
</div>
</span>
<div><a href="">http://www.blogjava.net/1504/admin/EditPosts.aspx</a></div>
</span>
<div></div>
</span>
<div></div>
</span>
<div></div>
</span>
<div></div>
</span>
<div><br />
</div>
<img src ="http://www.blogjava.net/1504/aggbug/340088.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2010-12-08 19:41 <a href="http://www.blogjava.net/1504/archive/2010/12/08/340088.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>js url传值乱码解决【总结备用】</title><link>http://www.blogjava.net/1504/archive/2010/10/10/334224.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Sun, 10 Oct 2010 13:42:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2010/10/10/334224.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/334224.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2010/10/10/334224.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/334224.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/334224.html</trackback:ping><description><![CDATA[<div>1、function openWins()</div>
<div>{</div>
<div>&nbsp;&nbsp; try</div>
<div>&nbsp;&nbsp; {</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var apply_id='1001';</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;currentTitle=encodeURI(encodeURI(currentTitle));</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var srcFile = "org!addOrg.do?flag="+apply_id+"&amp;title="+currentTitle+"&amp;id="+currentId;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var winFeatures = "dialogWidth=450px;dialogHeight=300px;status=no;help=no;";&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var seleItemValue='2010';</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var ret = window.showModalDialog(srcFile, seleItemValue, winFeatures);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;onclickeReturn(ret);</div>
<div>&nbsp;&nbsp; }</div>
<div>&nbsp;&nbsp; catch(e)</div>
<div>&nbsp;&nbsp; {</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;alert(e);</div>
<div>&nbsp;&nbsp; }</div>
<div>}</div>
<div>2、String title=request.getParameter("title");</div>
<div>title=java.net.URLDecoder.decode(title,"utf-8");</div>
<img src ="http://www.blogjava.net/1504/aggbug/334224.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2010-10-10 21:42 <a href="http://www.blogjava.net/1504/archive/2010/10/10/334224.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>配置Apache 隐藏版本号及其它敏感信息详解 </title><link>http://www.blogjava.net/1504/archive/2010/08/13/328792.html</link><dc:creator>weesun一米阳光</dc:creator><author>weesun一米阳光</author><pubDate>Fri, 13 Aug 2010 08:07:00 GMT</pubDate><guid>http://www.blogjava.net/1504/archive/2010/08/13/328792.html</guid><wfw:comment>http://www.blogjava.net/1504/comments/328792.html</wfw:comment><comments>http://www.blogjava.net/1504/archive/2010/08/13/328792.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/1504/comments/commentRss/328792.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/1504/services/trackbacks/328792.html</trackback:ping><description><![CDATA[<span style="font-size: 10pt">默认情况下，很多Apache安装时会显示版本号及操作系统版本，甚至会显示服务器上安装的是什么样的Apache模块。这些信息可以为黑客所用，并且黑客还可以从中得知你所配置的服务器上的很多设置都是默认状态。 <br />
<br />
　　这里有两条语句，你需要添加到你的httpd.conf文件中： <br />
<br />
　　ServerSignature Off <br />
<br />
　　ServerTokens Prod <br />
<br />
　　ServerSignature出现在Apache所产生的像404页面、目录列表等页面的底部。ServerTokens目录被用来判断 Apache会在Server HTTP响应包的头部填充什么信息。如果把ServerTokens设为Prod，那么HTTP响应包头就会被设置成： <br />
<br />
　　Server：Apache <br />
<br />
　　如果你非常想尝试其它事物，你可以通过编辑源代码改成不是Apache的其它东西，或者你可以通过下面将要介绍的mod_security实现。 </span>
<img src ="http://www.blogjava.net/1504/aggbug/328792.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/1504/" target="_blank">weesun一米阳光</a> 2010-08-13 16:07 <a href="http://www.blogjava.net/1504/archive/2010/08/13/328792.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>