﻿<?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-Enjoying Life ...... !</title><link>http://www.blogjava.net/lippea/</link><description>If u can look into my eyes,
u will see how beautiful the life is.</description><language>zh-cn</language><lastBuildDate>Tue, 28 Apr 2026 19:00:08 GMT</lastBuildDate><pubDate>Tue, 28 Apr 2026 19:00:08 GMT</pubDate><ttl>60</ttl><item><title>取未知类型对象的属性值</title><link>http://www.blogjava.net/lippea/archive/2005/05/25/5188.html</link><dc:creator>lippea'blog</dc:creator><author>lippea'blog</author><pubDate>Wed, 25 May 2005 07:42:00 GMT</pubDate><guid>http://www.blogjava.net/lippea/archive/2005/05/25/5188.html</guid><wfw:comment>http://www.blogjava.net/lippea/comments/5188.html</wfw:comment><comments>http://www.blogjava.net/lippea/archive/2005/05/25/5188.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/lippea/comments/commentRss/5188.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lippea/services/trackbacks/5188.html</trackback:ping><description><![CDATA[<FONT color=#000000><STRONG>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; TEXT-ALIGN: left; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt; mso-pagination: widow-orphan" align=left><FONT face=Arial><FONT face="Times New Roman" size=1><STRONG><SPAN style="FONT-WEIGHT: normal; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 7.5pt"><SPAN style="FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">讨论编写复杂<SPAN lang=EN-US>struts</SPAN>标签时，需要在已知对象和其属性名称的情况下取得该对象中对应的属性值。但是对于传过来的数据并不知道其数据类型，即时使用<SPAN lang=EN-US>Object.getClass()</SPAN>得到其数据类型，也不可能提前引入相关的类。将<SPAN lang=EN-US>struts</SPAN>的<SPAN lang=EN-US>logic.iterate</SPAN>和<SPAN lang=EN-US>bean:write</SPAN>反编译后详细研究，得到下列代码：</SPAN></SPAN></STRONG></FONT></FONT></P>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 3pt; BORDER-LEFT: windowtext 0.5pt solid; PADDING-TOP: 3pt; BORDER-BOTTOM: windowtext 0.5pt solid">
<P class=MsoNormal style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: medium none; PADDING-LEFT: 0cm; PADDING-BOTTOM: 0cm; MARGIN: 0cm 0cm 0pt; BORDER-LEFT: medium none; WORD-BREAK: break-all; PADDING-TOP: 0cm; BORDER-BOTTOM: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 3.0pt 5.0pt 3.0pt 5.0pt"><SPAN lang=EN-US style="COLOR: black; mso-bidi-font-size: 7.5pt"><?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></v:path><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape id=_x0000_i1025 style="WIDTH: 8.25pt; HEIGHT: 12pt" type="#_x0000_t75" alt=""><v:imagedata o:HREF="/Images/OutliningIndicators/None.gif" src="file:///C:/DOCUME~1/黄凤鸣/LOCALS~1/Temp/msoclip1/01/clip_image001.gif"><FONT face=Arial size=1></FONT></v:imagedata></v:shape><STRONG><SPAN style="FONT-WEIGHT: normal"><FONT face=Arial size=1>Object&nbsp;propertyValue&nbsp;=&nbsp;PropertyUtils.getProperty(</FONT></SPAN></STRONG></SPAN><FONT face=Arial><FONT size=1><STRONG><SPAN lang=EN-US style="FONT-WEIGHT: normal; mso-bidi-font-size: 7.5pt">object<SPAN style="COLOR: black">,&nbsp;propertyName)</SPAN></SPAN></STRONG><SPAN lang=EN-US><o:p></o:p></SPAN></FONT></FONT></P></DIV>
<P><FONT face=Arial><FONT size=1><STRONG><SPAN lang=EN-US style="FONT-WEIGHT: normal; FONT-SIZE: 10.5pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 7.5pt; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">object</SPAN></STRONG><STRONG><SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 10.5pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 7.5pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">为对象，</SPAN></STRONG><STRONG><SPAN lang=EN-US style="FONT-WEIGHT: normal; FONT-SIZE: 10.5pt; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 7.5pt; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">propertyName</SPAN></STRONG><STRONG><SPAN style="FONT-WEIGHT: normal; FONT-SIZE: 10.5pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 7.5pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">为需要得到的属性名称，返回的是该对象中对应属性的值。试验可以使用。</SPAN></STRONG></FONT></FONT></STRONG></FONT></P><img src ="http://www.blogjava.net/lippea/aggbug/5188.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lippea/" target="_blank">lippea'blog</a> 2005-05-25 15:42 <a href="http://www.blogjava.net/lippea/archive/2005/05/25/5188.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用正则表达式</title><link>http://www.blogjava.net/lippea/archive/2005/05/25/5184.html</link><dc:creator>lippea'blog</dc:creator><author>lippea'blog</author><pubDate>Wed, 25 May 2005 07:31:00 GMT</pubDate><guid>http://www.blogjava.net/lippea/archive/2005/05/25/5184.html</guid><wfw:comment>http://www.blogjava.net/lippea/comments/5184.html</wfw:comment><comments>http://www.blogjava.net/lippea/archive/2005/05/25/5184.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lippea/comments/commentRss/5184.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lippea/services/trackbacks/5184.html</trackback:ping><description><![CDATA[<P><FONT size=1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一直觉得这东西很神秘，昨天要求校验数据类型，想自己写方法的时候突然想到这个它，上网查了一下。它最简单的形式是：</FONT></P>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<P><FONT size=1><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">Pattern.matches(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">[0-9]*</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;szInput);</SPAN></FONT></P></DIV>
<P><FONT size=1>szInput是需要校验的字符串。拆开写就是：</FONT></P>
<DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
<P><FONT size=1><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">Pattern&nbsp;p&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Pattern.compile(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">[0-9]*</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=1><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Matcher&nbsp;m&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT size=1><SPAN style="COLOR: #000000">&nbsp;p.matcher(szInput);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>boolean&nbsp;b&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;m.matches();&nbsp;</SPAN></FONT></P></DIV>
<P><FONT size=1>详细的规则可以参见java帮助文档中的java.util.regex部分。</FONT></P><img src ="http://www.blogjava.net/lippea/aggbug/5184.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lippea/" target="_blank">lippea'blog</a> 2005-05-25 15:31 <a href="http://www.blogjava.net/lippea/archive/2005/05/25/5184.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用Eclipse创建模板并格式化代码(续)</title><link>http://www.blogjava.net/lippea/archive/2005/05/09/4108.html</link><dc:creator>lippea'blog</dc:creator><author>lippea'blog</author><pubDate>Mon, 09 May 2005 02:46:00 GMT</pubDate><guid>http://www.blogjava.net/lippea/archive/2005/05/09/4108.html</guid><wfw:comment>http://www.blogjava.net/lippea/comments/4108.html</wfw:comment><comments>http://www.blogjava.net/lippea/archive/2005/05/09/4108.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/lippea/comments/commentRss/4108.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lippea/services/trackbacks/4108.html</trackback:ping><description><![CDATA[<FONT color=#000000>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">昨天把之前的想法和</SPAN><SPAN lang=EN-US style="COLOR: black">yj</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">交流后，发现其中缺失代码格式化中很重要的一块，就是每个方法的注释。方法注释用于说明该方法的各项信息，比如创建人、创建日期、主要功能及输入输出的说明。另外还了解到规范化方法注释可以用于自动生成</SPAN><SPAN lang=EN-US style="COLOR: black">JavaDoc</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，看起来和</SPAN><SPAN lang=EN-US style="COLOR: black">Java</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">帮助文档很类似的项目说明文档。</SPAN><SPAN lang=EN-US style="COLOR: black"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">今天找到</SPAN><SPAN lang=EN-US style="COLOR: black">eclipse</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中设置方法注释模板并使用方法注释的方法。</SPAN><SPAN lang=EN-US style="COLOR: black"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置方法注释模板：选择</SPAN><SPAN lang=EN-US style="COLOR: black">eclipse</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">菜单栏中【窗口】下的【首选项】，展开左边树到</SPAN><SPAN lang=EN-US style="COLOR: black">Java-&gt;</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码样式</SPAN><SPAN lang=EN-US style="COLOR: black">-&gt;</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码模板，展开右边出现的对话框中的注释</SPAN><SPAN lang=EN-US style="COLOR: black">-&gt;</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法，点击右边的【编辑】按钮。编辑其中的内容。也可以点击下面的【插入变量】按钮添加变量。例如：</SPAN><SPAN lang=EN-US style="COLOR: black"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">/**</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">*</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white"> </SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #7f9fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">@author</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white"> </SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">${user}</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">*</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white"> </SPAN><SPAN style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">功能：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">*</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white"> </SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">${tags}<BR></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: #3f5fbf; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-highlight: white">&nbsp;*/</SPAN><SPAN lang=EN-US style="mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其中</SPAN><SPAN lang=EN-US>@author</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是</SPAN><SPAN lang=EN-US>JavaDoc</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的标示，带</SPAN><SPAN lang=EN-US>$</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">符号的是变量。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使用时鼠标放置在需要添加注释的方法内部的任意位置。点击菜单栏中<SPAN style="COLOR: black">【源代码】下的【添加</SPAN></SPAN><SPAN lang=EN-US style="COLOR: black">Javadoc</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">注释】，或者使用快捷键</SPAN><SPAN lang=EN-US style="COLOR: black">Alt+Shift+J</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，则</SPAN><SPAN lang=EN-US style="COLOR: black">eclipse</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">自动在该方法前面添加注释，例如</SPAN><SPAN lang=EN-US style="COLOR: black">public static void main(String[] args)</SPAN><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">生成如下注释：</SPAN><SPAN lang=EN-US style="COLOR: black"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>/**</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>* @author </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">hfm</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>* </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">功能：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>* @param args</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>*/<BR></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当然添加完之后还需要手动添加其中的各项内容，如方法的功能和参数的含义等。</SPAN></SPAN></FONT></P><img src ="http://www.blogjava.net/lippea/aggbug/4108.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lippea/" target="_blank">lippea'blog</a> 2005-05-09 10:46 <a href="http://www.blogjava.net/lippea/archive/2005/05/09/4108.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用Eclipse创建模板并格式化代码</title><link>http://www.blogjava.net/lippea/archive/2005/04/30/3976.html</link><dc:creator>lippea'blog</dc:creator><author>lippea'blog</author><pubDate>Sat, 30 Apr 2005 10:10:00 GMT</pubDate><guid>http://www.blogjava.net/lippea/archive/2005/04/30/3976.html</guid><wfw:comment>http://www.blogjava.net/lippea/comments/3976.html</wfw:comment><comments>http://www.blogjava.net/lippea/archive/2005/04/30/3976.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/lippea/comments/commentRss/3976.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/lippea/services/trackbacks/3976.html</trackback:ping><description><![CDATA[<P class=MsoBodyTextIndent style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上次听了其他项目组介绍在编写完代码后使用代码格式化程序对代码进行格式化，有利于版本冲突时进行对比和文件合并。想到当前代码编写格式多少有些太个性化，如果可以创建一份代码模板，将之导入到所有人的工具中，然后所有的代码在编写后都进行格式化，则避免了代码格式太混乱的情况，有利于大家阅读代码。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US>Eclipse</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有内置的代码格式化程序和模板，也可以创建自己的模板：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在菜单栏中选中</SPAN><SPAN style="FONT-FAMILY: 宋体">『窗口』<SPAN lang=EN-US>-〉『首选项』。在出现的对话框的左边树中展开『Java』下的『代码样式』。其中有两项，一项是『代码格式化程序』，另一项是『代码模板』。主要的是设置『代码格式化程序』，『代码模板』中设置的是自动生成的代码的格式，比如setter和getter方法的代码及相关注释。<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体">设置『代码格式化程序』：<SPAN lang=EN-US>Eclipse内置的模板不能导出，需要新建一个。输入模板名称，并选择初始化设置的文件。这部分主要是设置格式化后代码的格式，包括缩进、空行、花括弧等等内容。具体的东西就按照自己的爱好，自己慢慢确定吧。然后点击导出，存成.xml文件。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体">设置『代码模板』没有什么，主要是设置自动生成的一些方法等的注释格式，如getter/setter方法的注释。里面可以包括一些变量，可以生成时自动填充相应内容，如姓名，参数名称等。设置完毕后，点击全部导出，存成<SPAN lang=EN-US>.xml文件。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN lang=EN-US style="FONT-FAMILY: 宋体">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 27pt; mso-char-indent-count: 2.57; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体">用的时候当然是分别点击导入按钮，选择正确的配置文件。选中菜单栏中『源代码』下的格式化，或者使用快捷方式<SPAN lang=EN-US>ctrl+shift+f对代码进行格式化。OK!</SPAN></SPAN></P><img src ="http://www.blogjava.net/lippea/aggbug/3976.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/lippea/" target="_blank">lippea'blog</a> 2005-04-30 18:10 <a href="http://www.blogjava.net/lippea/archive/2005/04/30/3976.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>