﻿<?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-午夜拍键惊奇-随笔分类-Java 点滴</title><link>http://www.blogjava.net/fidodido/category/2508.html</link><description>子夜 编程 代码与我同在</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 10:47:46 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 10:47:46 GMT</pubDate><ttl>60</ttl><item><title>“软件工业奥斯卡”SYS-CON读者选择奖： Java开发（转载自CSDN）</title><link>http://www.blogjava.net/fidodido/archive/2006/03/13/35027.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Mon, 13 Mar 2006 06:24:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2006/03/13/35027.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/35027.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2006/03/13/35027.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/35027.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/35027.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: SYS-CON 媒体（www.sys-con.com）在近日揭晓了一年一度的“读者选择奖”，这个奖项有“软件工业奥斯卡”之称。今年是第10届，有超过1.7万的SYS-CON读者参与了投票，分别评选出了在SOA、Web Services、Java和XML技术等领域的最佳产品、工具以及最佳提名。&nbsp;I 最佳Java应用服务器获胜者：BEA WebLogic Server (BEA ...&nbsp;&nbsp;<a href='http://www.blogjava.net/fidodido/archive/2006/03/13/35027.html'>阅读全文</a><img src ="http://www.blogjava.net/fidodido/aggbug/35027.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2006-03-13 14:24 <a href="http://www.blogjava.net/fidodido/archive/2006/03/13/35027.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java API中文版[转载自Sun技术社区]</title><link>http://www.blogjava.net/fidodido/archive/2005/11/08/18806.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Tue, 08 Nov 2005 09:00:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/11/08/18806.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/18806.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/11/08/18806.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/18806.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/18806.html</trackback:ping><description><![CDATA[<TABLE style="WIDTH: 100%" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD class=bai01 style="VERTICAL-ALIGN: bottom; HEIGHT: 16px; BACKGROUND-COLOR: rgb(204,204,204); TEXT-ALIGN: center"><STRONG><SPAN style="COLOR: rgb(51,51,255)">Java API 文档中文版</SPAN></STRONG></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=5 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=a01 vAlign=top><SPAN style="FONT-FAMILY: 宋体"><SPAN style="FONT-WEIGHT: bold"></SPAN></SPAN>
<P class=MsoNormal><B><SPAN lang=EN-US style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体"><?XML:NAMESPACE PREFIX = O /><O:P></O:P></SPAN></B></P><BR>Sun 公司提供的Java API Docs是学习和使用Java语言中最经常使用的参考资料之一。但是长期以来此文档只有英文版，对于中国地区的Java开发者来说相当的不便。目前Sun 公司正在组织多方力量将此文档翻译成中文，并于近日在Sun 中国技术社区（http://gceclub.sun.com.cn/）正式发布java.lang和java.util类库API 文档的中文版，其他类库API文档的中文版也将于今后一段时间内陆续向中国地区的开发人员提供。在J2SE API文档（5.0版本）的汉化工作完成之后，Sun 中国技术社区还将开通Java API 文档中文版的打包下载服务。<BR><BR><SPAN style="FONT-WEIGHT: bold; COLOR: rgb(51,51,255)">Java API　文档中文版发布计划</SPAN><BR><BR>
<TABLE style="WIDTH: 100%; TEXT-ALIGN: left" cellSpacing=2 cellPadding=2 border=0>
<TBODY>
<TR>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,204,255)">发布时间</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,204,255)">相关类库</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,204,255)">阅读/下载</TD></TR>
<TR>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)">2005/10/31</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)">java.lang<BR>java.util<BR></TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)"><A href="http://gceclub.sun.com.cn/download/Java_Docs/html/zh_CN/api/index.html">在线阅读</A></TD></TR>
<TR>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)">2005/12/31</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)">java.awt<BR>java.io<BR>java.text<BR></TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)"><BR></TD></TR>
<TR>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)">2006/02/28</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)">java.swing<BR></TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)"></TD></TR>
<TR>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)">2006/03/31</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)"><PRE>java.applet<BR>java.beans<BR>java.maths<BR>java.net<BR>java.nio<BR>java.rmi<BR>java.security<BR>java.sql <BR>javax.accessibility <BR>javax.activity<BR>javax.crypto</PRE></TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)"></TD></TR>
<TR>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)">2006/04/30</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)"><PRE>javax.imageio<BR>javax.management<BR>javax.net<BR>javax.naming<BR>javax.print<BR>javax.rmi<BR>javax.security<BR>javax.sound</PRE></TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(204,255,255)"></TD></TR>
<TR>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)">2006/05/31</TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)"><PRE>javax.sql<BR>javax.transaction<BR>javax.xml<BR>org.ietf<BR>org.xml<BR>org.w3c<BR>org.omg</PRE></TD>
<TD style="VERTICAL-ALIGN: top; BACKGROUND-COLOR: rgb(255,255,153)"><BR></TD></TR></TBODY></TABLE><BR></TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/fidodido/aggbug/18806.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-11-08 17:00 <a href="http://www.blogjava.net/fidodido/archive/2005/11/08/18806.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用FilterServlet对页面进行转码</title><link>http://www.blogjava.net/fidodido/archive/2005/11/04/18185.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Fri, 04 Nov 2005 11:42:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/11/04/18185.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/18185.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/11/04/18185.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/18185.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/18185.html</trackback:ping><description><![CDATA[相信很多朋友在使用JSP/Servlet等技术进行页面编程的时候都会或多或少地遇到乱码问题。解决的方法有很多，比较常见的是手动对所有可能包含中文的字符串进行转码：<BR><BR>
<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"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">String&nbsp;latin&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>String&nbsp;gbk&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;String(latin.getBytes(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">iso-8859-1</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">),</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">gbk</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);</SPAN></DIV><BR>这个方法过去我也比较常用，的确有效，但很累赘耶，丝毫没有模式之美，有没有更优雅的方法呢？如果你和我一样有疑虑的话，可以考虑使用FilterServlet：<BR><BR>
<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: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">&nbsp;java.io.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">&nbsp;javax.servlet.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">&nbsp;javax.servlet.http.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">&nbsp;org.apache.log4j.</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;CharsetFilter<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_168_917_Open_Image onclick="this.style.display='none'; Codehighlighter1_168_917_Open_Text.style.display='none'; Codehighlighter1_168_917_Closed_Image.style.display='inline'; Codehighlighter1_168_917_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_168_917_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_168_917_Closed_Text.style.display='none'; Codehighlighter1_168_917_Open_Image.style.display='inline'; Codehighlighter1_168_917_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">extends</SPAN><SPAN style="COLOR: #000000">&nbsp;HttpServlet&nbsp;</SPAN><SPAN style="COLOR: #0000ff">implements</SPAN><SPAN style="COLOR: #000000">&nbsp;Filter</SPAN><SPAN id=Codehighlighter1_168_917_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_168_917_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;Logger&nbsp;logger&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Logger.getLogger(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Filter&nbsp;servlet</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;init(FilterConfig&nbsp;filterConfig)<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_315_319_Open_Image onclick="this.style.display='none'; Codehighlighter1_315_319_Open_Text.style.display='none'; Codehighlighter1_315_319_Closed_Image.style.display='inline'; Codehighlighter1_315_319_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_315_319_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_315_319_Closed_Text.style.display='none'; Codehighlighter1_315_319_Open_Image.style.display='inline'; Codehighlighter1_315_319_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">throws</SPAN><SPAN style="COLOR: #000000">&nbsp;ServletException</SPAN><SPAN id=Codehighlighter1_315_319_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_315_319_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;doFilter(ServletRequest&nbsp;request,ServletResponse&nbsp;response,<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_424_885_Open_Image onclick="this.style.display='none'; Codehighlighter1_424_885_Open_Text.style.display='none'; Codehighlighter1_424_885_Closed_Image.style.display='inline'; Codehighlighter1_424_885_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_424_885_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_424_885_Closed_Text.style.display='none'; Codehighlighter1_424_885_Open_Image.style.display='inline'; Codehighlighter1_424_885_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FilterChain&nbsp;filterChain)</SPAN><SPAN id=Codehighlighter1_424_885_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_424_885_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_449_740_Open_Image onclick="this.style.display='none'; Codehighlighter1_449_740_Open_Text.style.display='none'; Codehighlighter1_449_740_Closed_Image.style.display='inline'; Codehighlighter1_449_740_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_449_740_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_449_740_Closed_Text.style.display='none'; Codehighlighter1_449_740_Open_Image.style.display='inline'; Codehighlighter1_449_740_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(request&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_449_740_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_449_740_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;charset&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;request.getCharacterEncoding();<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(charset&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">||</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">charset.equalsIgnoreCase(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">gbk</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">))<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_579_636_Open_Image onclick="this.style.display='none'; Codehighlighter1_579_636_Open_Text.style.display='none'; Codehighlighter1_579_636_Closed_Image.style.display='inline'; Codehighlighter1_579_636_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_579_636_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_579_636_Closed_Text.style.display='none'; Codehighlighter1_579_636_Open_Image.style.display='inline'; Codehighlighter1_579_636_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN id=Codehighlighter1_579_636_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_579_636_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;request.setCharacterEncoding(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">GBK</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_684_734_Open_Image onclick="this.style.display='none'; Codehighlighter1_684_734_Open_Text.style.display='none'; Codehighlighter1_684_734_Closed_Image.style.display='inline'; Codehighlighter1_684_734_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_684_734_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_684_734_Closed_Text.style.display='none'; Codehighlighter1_684_734_Open_Image.style.display='inline'; Codehighlighter1_684_734_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(UnsupportedEncodingException&nbsp;ex)</SPAN><SPAN id=Codehighlighter1_684_734_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_684_734_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logger.warn(ex.getMessage());<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_749_813_Open_Image onclick="this.style.display='none'; Codehighlighter1_749_813_Open_Text.style.display='none'; Codehighlighter1_749_813_Closed_Image.style.display='inline'; Codehighlighter1_749_813_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_749_813_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_749_813_Closed_Text.style.display='none'; Codehighlighter1_749_813_Open_Image.style.display='inline'; Codehighlighter1_749_813_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN id=Codehighlighter1_749_813_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_749_813_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filterChain.doFilter(request,response);&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;递交责任链下一环</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_838_881_Open_Image onclick="this.style.display='none'; Codehighlighter1_838_881_Open_Text.style.display='none'; Codehighlighter1_838_881_Closed_Image.style.display='inline'; Codehighlighter1_838_881_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_838_881_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_838_881_Closed_Text.style.display='none'; Codehighlighter1_838_881_Open_Image.style.display='inline'; Codehighlighter1_838_881_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(Exception&nbsp;ex)</SPAN><SPAN id=Codehighlighter1_838_881_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_838_881_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logger.error(ex.getMessage());<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_911_915_Open_Image onclick="this.style.display='none'; Codehighlighter1_911_915_Open_Text.style.display='none'; Codehighlighter1_911_915_Closed_Image.style.display='inline'; Codehighlighter1_911_915_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_911_915_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_911_915_Closed_Text.style.display='none'; Codehighlighter1_911_915_Open_Image.style.display='inline'; Codehighlighter1_911_915_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;destroy()</SPAN><SPAN id=Codehighlighter1_911_915_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_911_915_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR>FilterServlet内部应该使用责任链（Chain of Responsibility）实现，在这里我们把对字符串的转码做为责任链中的一环，从上一环拿到request，处理后交给链的下一环。另外需要在web.xml里做些配置：<BR><BR>
<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"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">filter</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">filter-name</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">charsetfilter</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">filter-name</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">filter-class</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">pqp.servlet.CharsetFilter</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">filter-class</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">filter</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">filter-mapping</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">filter-name</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">charsetfilter</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">filter-name</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">url-pattern</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">/*</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">url-pattern</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">dispatcher</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">REQUEST</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">dispatcher</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">filter-mapping</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV><BR>其中“REQUEST”指定了filter拦截的类型，有REQUEST、FORWARD、ERROR和INCLUDE，可组合选择，一般选REQUEST。全部设置好后重新打包、部署，这样Servlet就可以自动把所有的request转换为GBK的字符集了，是不是很方便？<IMG height=19 src="http://www.blogjava.net/Emoticons/teeth_smile.gif" width=19 border=0>但在这里加了filter后对性能方面的影响未知，大家可以讨论一下。<img src ="http://www.blogjava.net/fidodido/aggbug/18185.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-11-04 19:42 <a href="http://www.blogjava.net/fidodido/archive/2005/11/04/18185.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.util.Calendar中的陷阱</title><link>http://www.blogjava.net/fidodido/archive/2005/10/24/16604.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Mon, 24 Oct 2005 09:23:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/10/24/16604.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/16604.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/10/24/16604.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/16604.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/16604.html</trackback:ping><description><![CDATA[<P>需求：<BR>从输入框得到用户分开输入的年、月、日，将信息做为Date类型插入数据库</P>
<P>解决一：</P>
<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"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">InputBean&nbsp;bean&nbsp;=&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;InputBean();&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;封装用户输入<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;获取用户输入，封装于bean对象中</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Calendar&nbsp;cal&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Calendar.getInstance();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>cal.set(cal.YEAR,bean.getYear());&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Year</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">cal.set(cal.MONTH,bean.getMonth());&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Month</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">cal.set(cal.DAY_OF_MONTH,bean.getDay());&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Day<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;数据库操作</SPAN></DIV>
<P>陷阱：<BR>Calendar中的MONTH字段和数组下标一样，<FONT color=#ffa500>从0开始，</FONT><FONT color=#ffa500>0代表Calendar.JANUARY，1代表Calendar.FEBUARY……12代表次年Calendar.JANUARY</FONT>。因此用户输入的月份在置入Calendar对象之前必须进行处理，即减一。<BR><BR>解决二：</P>
<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"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">InputBean&nbsp;bean&nbsp;=&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;InputBean();&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;封装用户输入<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;获取用户输入，封装于bean对象中</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Calendar&nbsp;cal&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Calendar.getInstance();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>cal.set(cal.YEAR,bean.getYear());&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Year</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">cal.set(cal.MONTH,bean.getMonth()&nbsp;</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">);&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Month</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">cal.set(cal.DAY_OF_MONTH,bean.getDay());&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Day<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;数据库操作</SPAN></DIV><img src ="http://www.blogjava.net/fidodido/aggbug/16604.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-10-24 17:23 <a href="http://www.blogjava.net/fidodido/archive/2005/10/24/16604.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>奇怪的范型定义</title><link>http://www.blogjava.net/fidodido/archive/2005/10/19/15971.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Wed, 19 Oct 2005 10:14:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/10/19/15971.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/15971.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/10/19/15971.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/15971.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/15971.html</trackback:ping><description><![CDATA[java.util.Collections 类中两个sort方法的定义很奇怪，哪位能给解释一下：<BR><BR>public static &lt;T&gt; void <B>sort</B>(<A title="interface in java.util" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html">List</A>&lt;T&gt;&nbsp;list,&nbsp; <A title="interface in java.util" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html">Comparator</A>&lt;? super T&gt;&nbsp;c)<BR>1、既然该方法无返回值（void），第一个“&lt;T&gt;”有什么作用？<BR>2、“?”代表什么含义？<BR>3、“super”起什么作用？<BR>4、基于2、3：“&lt;? super T&gt;”如何理解？<BR><BR>public static &lt;T extends <A title="interface in java.lang" href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Comparable.html">Comparable</A>&lt;? super T&gt;&gt; void <B>sort</B>(<A title="interface in java.util" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html">List</A>&lt;T&gt;&nbsp;list)<BR>1、“extends”如何理解？<BR>2、其余同上<img src ="http://www.blogjava.net/fidodido/aggbug/15971.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-10-19 18:14 <a href="http://www.blogjava.net/fidodido/archive/2005/10/19/15971.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java Concurrent框架之阻塞队列（Blocking queue）</title><link>http://www.blogjava.net/fidodido/archive/2005/10/11/15269.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Tue, 11 Oct 2005 08:56:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/10/11/15269.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/15269.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/10/11/15269.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/15269.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/15269.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 引子：大家上过操作系统的都知道“生产者－消费者（Producer-Consumer）”模型，主要讨论的是进程（线程）间的互斥和同步问题，关键是对锁（lock）的申请、独占和释放，在这里我就不罗嗦了。原先我写的Java代码如下：public&nbsp;class&nbsp;Producer&nbsp;extends&nbsp;Thread{&nbsp;&nbsp;private&nbsp;Pro...&nbsp;&nbsp;<a href='http://www.blogjava.net/fidodido/archive/2005/10/11/15269.html'>阅读全文</a><img src ="http://www.blogjava.net/fidodido/aggbug/15269.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-10-11 16:56 <a href="http://www.blogjava.net/fidodido/archive/2005/10/11/15269.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java code name</title><link>http://www.blogjava.net/fidodido/archive/2005/10/10/15181.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Mon, 10 Oct 2005 14:54:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/10/10/15181.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/15181.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/10/10/15181.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/15181.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/15181.html</trackback:ping><description><![CDATA[<TABLE style="MARGIN-LEFT: 4em" cellSpacing=0 cellPadding=5 border=0>
<TBODY>
<TR>
<TH style="FONT-SIZE: 95%; BORDER-BOTTOM: 1px solid" align=left><B>VERSION</B> </TH>
<TH style="FONT-SIZE: 95%; BORDER-BOTTOM: 1px solid" align=left><B>CODE NAME</B></TH>
<TH style="FONT-SIZE: 95%; BORDER-BOTTOM: 1px solid" align=middle>&nbsp;&nbsp;<B>RELEASE DATE</B></TH></TR>
<TR>
<TD>JDK 1.1.4</TD>
<TD>Sparkler</TD>
<TD align=right>Sept 12, 1997</TD></TR>
<TR>
<TD>JDK 1.1.5</TD>
<TD>Pumpkin</TD>
<TD align=right>Dec 3, 1997</TD></TR>
<TR>
<TD>JDK 1.1.6</TD>
<TD>Abigail</TD>
<TD align=right>April 24, 1998</TD></TR>
<TR>
<TD>JDK 1.1.7</TD>
<TD>Brutus</TD>
<TD align=right>Sept 28, 1998</TD></TR>
<TR>
<TD>JDK 1.1.8</TD>
<TD>Chelsea</TD>
<TD align=right>April 8, 1999</TD></TR>
<TR>
<TD><B>J2SE 1.2</B></TD>
<TD><B>Playground</B></TD>
<TD align=right><B>Dec 4, 1998</B></TD></TR>
<TR>
<TD>J2SE 1.2.1</TD>
<TD>(none)</TD>
<TD align=right>March 30, 1999</TD></TR>
<TR>
<TD>J2SE 1.2.2</TD>
<TD>Cricket</TD>
<TD align=right>July 8, 1999</TD></TR>
<TR>
<TD><B>J2SE 1.3</B></TD>
<TD><B>Kestrel</B></TD>
<TD align=right><B>May 8, 2000</B></TD></TR>
<TR>
<TD>J2SE 1.3.1</TD>
<TD>Ladybird</TD>
<TD align=right>May 17, 2001</TD></TR>
<TR>
<TD><B>J2SE 1.4.0</B></TD>
<TD><B>Merlin</B></TD>
<TD align=right><B>Feb 13, 2002</B></TD></TR>
<TR>
<TD>J2SE 1.4.1</TD>
<TD>Hopper</TD>
<TD align=right>Sept 16, 2002</TD></TR>
<TR>
<TD>J2SE 1.4.2</TD>
<TD>Mantis</TD>
<TD align=right>June 26, 2003</TD></TR>
<TR>
<TD><B>J2SE 5.0 (1.5.0)</B></TD>
<TD><B>Tiger</B></TD>
<TD align=right><B>Sept 29, 2004</B></TD></TR>
<TR>
<TD colSpan=2><BR><B>Future Releases</B> </TD>
<TR>
<TD><B>J2SE 6.0 (1.6.0)</B></TD>
<TD><B>Mustang</B></TD>
<TD align=right><I>Not yet released</I></TD></TR>
<TR>
<TD><B>J2SE 7.0 (1.7.0)</B></TD>
<TD><B>Dolphin</B></TD>
<TD align=right><I>Not yet released</I></TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/fidodido/aggbug/15181.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-10-10 22:54 <a href="http://www.blogjava.net/fidodido/archive/2005/10/10/15181.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat 5.5.9 不支持switch(&amp;lt;enum&amp;gt;)？</title><link>http://www.blogjava.net/fidodido/archive/2005/09/19/13439.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Mon, 19 Sep 2005 10:51:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/09/19/13439.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/13439.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/09/19/13439.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/13439.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/13439.html</trackback:ping><description><![CDATA[ServiceExceptionType：<BR>
<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"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">package</SPAN><SPAN style="COLOR: #000000">&nbsp;pqp.service;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_54_125_Open_Image onclick="this.style.display='none'; Codehighlighter1_54_125_Open_Text.style.display='none'; Codehighlighter1_54_125_Closed_Image.style.display='inline'; Codehighlighter1_54_125_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_54_125_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_54_125_Closed_Text.style.display='none'; Codehighlighter1_54_125_Open_Image.style.display='inline'; Codehighlighter1_54_125_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">enum</SPAN><SPAN style="COLOR: #000000">&nbsp;ServiceExceptionType</SPAN><SPAN id=Codehighlighter1_54_125_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_54_125_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;DB_FAILURE<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,USER_EXISTED<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;,INVALID_USERNAME_OR_PASSWORD<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><BR>在新用户注册的逻辑方法中会检查用户名是否已存在，存在的话抛出ServiceException，并将ServiceExceptionType封装进去。action的excute不处理ServiceException，接着往外扔，最后由error.jsp处理：<BR>
<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"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000">@&nbsp;page&nbsp;contentType</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">text/html;&nbsp;charset=GBK</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000">@&nbsp;page&nbsp;isErrorPage</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">true</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000">@&nbsp;page&nbsp;</SPAN><SPAN style="COLOR: #0000ff">import</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">pqp.service.*</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>ServiceException&nbsp;ex</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">(ServiceException)exception;<BR><IMG id=Codehighlighter1_188_270_Open_Image onclick="this.style.display='none'; Codehighlighter1_188_270_Open_Text.style.display='none'; Codehighlighter1_188_270_Closed_Image.style.display='inline'; Codehighlighter1_188_270_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_188_270_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_188_270_Closed_Text.style.display='none'; Codehighlighter1_188_270_Open_Image.style.display='inline'; Codehighlighter1_188_270_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">switch</SPAN><SPAN style="COLOR: #000000">(ex.getType())</SPAN><SPAN id=Codehighlighter1_188_270_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_188_270_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;</SPAN><SPAN style="COLOR: #0000ff">case</SPAN><SPAN style="COLOR: #000000">&nbsp;USER_EXISTED:<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">无法注册：用户名“</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">ex.getMessage()</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">”已存在</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><BR>结果编译的时候报错：<BR><IMG height=610 alt=tomcat.png src="http://www.blogjava.net/images/blogjava_net/fidodido/2598/tomcat.png" width=761 border=0><BR><BR>难道Tomcat 5.5.9不支持对enumeration进行switch操作？<img src ="http://www.blogjava.net/fidodido/aggbug/13439.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-09-19 18:51 <a href="http://www.blogjava.net/fidodido/archive/2005/09/19/13439.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Joshua Bloch咏Tiger诗八首</title><link>http://www.blogjava.net/fidodido/archive/2005/09/08/12445.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Thu, 08 Sep 2005 08:59:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/09/08/12445.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/12445.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/09/08/12445.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/12445.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/12445.html</trackback:ping><description><![CDATA[<P>“Ease of Development”是J2SE 1.5的主要卖点。为此，这一版本加入了七种新的语言特性——Enhanced for Loop、Autoboxing/Auto-Unboxing、Varargs、Static Import、Enumeration、Metadata和Generics。使用这些特性，可以让编写出来的程序更简练、更清晰、更不容易出错，从而简化开发的过程。</P>
<P>Joshua Bloch（《Effective Java》的作者，J2SE 1.5的主要开发人员之一）效仿William Blake（1757-1827，英国诗人）的《<A href="http://www.daypoems.net/poems/441.html">Tiger</A>》一诗，为这些特性撰写了这样一组诗篇：</P>
<H4 class=major>咏Tiger</H4>
<BLOCKQUOTE>Tiger, Tiger burning bright<BR>Like a geek who works all night<BR>What new-fangled bit or byte<BR>Could ease the hacker"s weary plight?<BR></BLOCKQUOTE>
<P>这一首是总说Tiger中的能使开发变得简单的各种新语言特性。</P>
<H4 class=major>咏Enhanced for Loop</H4>
<BLOCKQUOTE>While Iterators have their uses<BR>They sometimes strangle us like nooses<BR>With enhanced-for"s deadly ray<BR>Iterator"s kept at bay<BR></BLOCKQUOTE>
<P>这一首单表Enhanced for Loop机制提供了一种更简单的遍历数组、Collection和其它实现了java.lang.Iterable接口的对象的方法。</P>
<H4 class=major>咏Autoboxing/Auto-Unboxing</H4>
<BLOCKQUOTE>When from the collections ints are drawn<BR>Wrapper classes make us mourn<BR>When Tiger comes, we"ll shed no tears<BR>We"ll autobox them in the ears<BR></BLOCKQUOTE>
<P>这一首单表Autoboxing机制/Auto-Unboxing提供了一种更简单的整合两套不同的类型系统（基本类型和引用类型）的机制。</P>
<H4 class=major>咏Varargs</H4>
<BLOCKQUOTE>O joyless nights, o joyless days<BR>Our programs cluttered with arrays<BR>With varargs here, we needn"t whine;<BR>We"ll simply put the args inline<BR></BLOCKQUOTE>
<P>这一首单表Varargs机制提供了一种更简单的传递个数可变的实参的方法。</P>
<H4 class=major>咏Static Import</H4>
<BLOCKQUOTE>And from the constant interface<BR>We shall inherit no disgrace<BR>With static import at our side<BR>Our joy will be unqualified<BR></BLOCKQUOTE>
<P>这一首单表Static Import机制提供了一种更简单的访问静态成员的机制。</P>
<H4 class=major>咏Enumeration</H4>
<BLOCKQUOTE>The int-enum will soon be gone<BR>Like a foe we"ve known too long.<BR>With type safe-enum"s mighty power<BR>Our foe will bother us no more<BR></BLOCKQUOTE>
<P>这一首单表Enumeration机制提供了一种更简单的定义“类型安全的枚举类”的方法。</P>
<H4 class=major>咏Metadata</H4>
<BLOCKQUOTE>As for noble metadata<BR>I"ll have to sing its praises later<BR>Its uses are so numerous<BR>To give their due, I"d miss the bus<BR></BLOCKQUOTE>
<P>这一首单表Metadata机制提供了一种更简单的定义“机器可读的说明信息”的机制。</P>
<H4 class=major>咏Generics</H4>
<BLOCKQUOTE>To the most despised collections" cast<BR>We"ll bid a fond farewell at last<BR>With generics" burning spear<BR>The need for cast will disappear<BR></BLOCKQUOTE>
<P>这一首是说用Generics机制，可以免去很多强制类型转化的步骤的事情。Generics机制还有些其它用法，在这里没有提到。</P><img src ="http://www.blogjava.net/fidodido/aggbug/12445.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-09-08 16:59 <a href="http://www.blogjava.net/fidodido/archive/2005/09/08/12445.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>接口与Object类的关系？</title><link>http://www.blogjava.net/fidodido/archive/2005/08/19/10506.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Fri, 19 Aug 2005 05:53:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/08/19/10506.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/10506.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/08/19/10506.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/10506.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/10506.html</trackback:ping><description><![CDATA[今天凌晨coding的时候发现一个很有趣的现象。“Object类是Java体系的单根父节点，所有Java类都从Object类继承。”这句话是大部分green hand都知道的Java金句，毋庸置疑。那如果我问你接口和Object类的关系呢？答案是“没有关系”。请看下面的代码：<BR><BR>
<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">
<DIV><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">Map&nbsp;map&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;HashMap();<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>map.clone();</SPAN></DIV></DIV><BR>Map是一个接口，HashMap是一个类。clone()方法在Object类中定义，因此我下意识认为第二行可以这么写。结果编译器报错：clone()方法未定义。这个错误让我很郁闷，看了半天doc才发祥原来Map是一个接口，而接口和Object类没有任何关系，所以Map也就没有继承clone()。于是把代码改成下面的样子：<BR><BR>
<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">
<DIV><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">HashMap&nbsp;map&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;HashMap();<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>map.clone();</SPAN></DIV></DIV><BR>这样就可以了。<img src ="http://www.blogjava.net/fidodido/aggbug/10506.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-08-19 13:53 <a href="http://www.blogjava.net/fidodido/archive/2005/08/19/10506.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>class文件中的秘密</title><link>http://www.blogjava.net/fidodido/archive/2005/08/04/9184.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Thu, 04 Aug 2005 04:50:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/08/04/9184.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/9184.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/08/04/9184.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/9184.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/9184.html</trackback:ping><description><![CDATA[<P>你知道class文件以16进制方式查看头4个字节是什么数据吗？“CAFEBABE”。没错，Cafe Baby。不信？用UltraEdit打开任何一个class文件自己看看吧</P><img src ="http://www.blogjava.net/fidodido/aggbug/9184.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-08-04 12:50 <a href="http://www.blogjava.net/fidodido/archive/2005/08/04/9184.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>static与final变量</title><link>http://www.blogjava.net/fidodido/archive/2005/08/04/9179.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Thu, 04 Aug 2005 04:27:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/08/04/9179.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/9179.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/08/04/9179.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/9179.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/9179.html</trackback:ping><description><![CDATA[<H4>一、illegal forward refrence</H4>
<P>前天写一个类时遇到一个很眼生的编译错误（问题简化后）：</P>
<P><FONT color=#339966></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">
<DIV><SPAN style="COLOR: #008080">1</SPAN><IMG id=Codehighlighter1_28_97_Open_Image onclick="this.style.display='none'; Codehighlighter1_28_97_Open_Text.style.display='none'; Codehighlighter1_28_97_Closed_Image.style.display='inline'; Codehighlighter1_28_97_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_28_97_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_28_97_Closed_Text.style.display='none'; Codehighlighter1_28_97_Open_Image.style.display='inline'; Codehighlighter1_28_97_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000">punlic&nbsp;final&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Constants</SPAN><SPAN id=Codehighlighter1_28_97_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_28_97_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;VAR2&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;VAR1&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;VAR1&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV></DIV>
<P></FONT>编译时出错（第2行）：</P>
<P>illegal forward refrence</P>
<P>仔细一想，是因为VAR2引用的VAR1在VAR2之后定义，看来在Java中定义static变量时应遵循“声明先于使用”的原则。<BR></P>
<P></P>
<H4>&nbsp;</H4>
<H4>二、static块</H4>
<P>还是上一个类，VAR1和VAR2定义成final，值存在一个properties文件中，在使用前必须将值load进来：</P>
<P>System.getProperties().load(new FileInputStream("constants.properties"));</P>
<P>于是将上面的代码放在static块中：<BR></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">
<DIV><IMG id=Codehighlighter1_28_278_Open_Image onclick="this.style.display='none'; Codehighlighter1_28_278_Open_Text.style.display='none'; Codehighlighter1_28_278_Closed_Image.style.display='inline'; Codehighlighter1_28_278_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_28_278_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_28_278_Closed_Text.style.display='none'; Codehighlighter1_28_278_Open_Image.style.display='inline'; Codehighlighter1_28_278_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000">punlic&nbsp;final&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Constants</SPAN><SPAN id=Codehighlighter1_28_278_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_28_278_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_38_120_Open_Image onclick="this.style.display='none'; Codehighlighter1_38_120_Open_Text.style.display='none'; Codehighlighter1_38_120_Closed_Image.style.display='inline'; Codehighlighter1_38_120_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_38_120_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_38_120_Closed_Text.style.display='none'; Codehighlighter1_38_120_Open_Image.style.display='inline'; Codehighlighter1_38_120_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN id=Codehighlighter1_38_120_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_38_120_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;System.getProperties().load(</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;FileInputStream(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">constants.properties</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;final&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;VAR2&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;System.getProperties().getProperty(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">var2</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;final&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;VAR1&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;System.getProperties().getProperty(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">var1</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV>
<P>但在运行时VAR1和VAR2没有被赋值，debug后发现static块根本没有执行。于是顿悟：final变量在编译时便被编译器计算、赋值，因此在运行时没有必要执行static块。</P><img src ="http://www.blogjava.net/fidodido/aggbug/9179.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-08-04 12:27 <a href="http://www.blogjava.net/fidodido/archive/2005/08/04/9179.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JBuilder 2005中的Servlet mapping</title><link>http://www.blogjava.net/fidodido/archive/2005/02/13/1149.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Sun, 13 Feb 2005 14:30:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/02/13/1149.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/1149.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/02/13/1149.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/1149.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/1149.html</trackback:ping><description><![CDATA[使用JB进行Servlet好像很方便的样子，但是servlet mapping我试了N遍才终于行了，“url pattern”里好向只能填“*.do”之类的东西，其它的一律不行。<B><BR></B><img src ="http://www.blogjava.net/fidodido/aggbug/1149.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-02-13 22:30 <a href="http://www.blogjava.net/fidodido/archive/2005/02/13/1149.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.util.StringTokenization</title><link>http://www.blogjava.net/fidodido/archive/2005/02/13/1148.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Sun, 13 Feb 2005 14:29:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/02/13/1148.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/1148.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/02/13/1148.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/1148.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/1148.html</trackback:ping><description><![CDATA[今天室友老七做数据库大作业，其中要实现一个功能，就是输入一个以“,”分隔的数字串，将得到的数字填入一个数组，他自己写了一个，很笨拙<IMG height=19 src="http://www.blogjava.net/Emoticons/shades_smile.gif" width=19 border=0>。我提议他用java.util.StringTokenization类。那个类使用起来很方便：<BR>
<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">
<DIV><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">StringTokenizer&nbsp;st&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;StringTokenizer(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">this&nbsp;is&nbsp;a&nbsp;test</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG id=Codehighlighter1_91_131_Open_Image onclick="this.style.display='none'; Codehighlighter1_91_131_Open_Text.style.display='none'; Codehighlighter1_91_131_Closed_Image.style.display='inline'; Codehighlighter1_91_131_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_91_131_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_91_131_Closed_Text.style.display='none'; Codehighlighter1_91_131_Open_Image.style.display='inline'; Codehighlighter1_91_131_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">&nbsp;(st.hasMoreTokens())&nbsp;</SPAN><SPAN id=Codehighlighter1_91_131_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_91_131_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(st.nextToken());<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV>&nbsp;<BR>输出：<BR><BR>this<BR>is<BR>a<BR>test<BR><BR>（构造器中第二个字符串是分隔符的集合，默认是空格）<B><BR></B><img src ="http://www.blogjava.net/fidodido/aggbug/1148.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-02-13 22:29 <a href="http://www.blogjava.net/fidodido/archive/2005/02/13/1148.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Java中使用Oracle blob</title><link>http://www.blogjava.net/fidodido/archive/2005/02/13/1145.html</link><dc:creator>^ Mustang ^</dc:creator><author>^ Mustang ^</author><pubDate>Sun, 13 Feb 2005 14:27:00 GMT</pubDate><guid>http://www.blogjava.net/fidodido/archive/2005/02/13/1145.html</guid><wfw:comment>http://www.blogjava.net/fidodido/comments/1145.html</wfw:comment><comments>http://www.blogjava.net/fidodido/archive/2005/02/13/1145.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/fidodido/comments/commentRss/1145.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/fidodido/services/trackbacks/1145.html</trackback:ping><description><![CDATA[<P><FONT size=2>Oracle中的lob (Large Object)可以存储非常大的数据（可能是4GB），这样就可以通过将文件或其它任何对象序列化成字节输出流(OutputStream)后写入数据库，之后使用字节输入流(InputStream)将数据读出然后反序列化为原始文件或对象。操作时需要使用oracle的JDBC包，它扩展了sun的JDBC包中的Blob对象。同时需要注意一些细节。下面的代码演示如何使用blob（实例中需要Oracle的JDBC包）。<BR><BR></FONT><FONT size=2><FONT color=#ffa500><FONT color=#800080></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">
<DIV><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">import&nbsp;oracle.jdbc.OracleResultSet;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;使用Oracle的ResultSet对象</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">import&nbsp;oracle.sql.BLOB;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;使用Oracle的BLOB对象，而不是sun的Blob</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><IMG src="http://www.blogjava.net/images/dot.gif"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_126_1086_Open_Image onclick="this.style.display='none'; Codehighlighter1_126_1086_Open_Text.style.display='none'; Codehighlighter1_126_1086_Closed_Image.style.display='inline'; Codehighlighter1_126_1086_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_126_1086_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_126_1086_Closed_Text.style.display='none'; Codehighlighter1_126_1086_Open_Image.style.display='inline'; Codehighlighter1_126_1086_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN id=Codehighlighter1_126_1086_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_126_1086_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;Connection&nbsp;conn</SPAN><SPAN style="COLOR: #000000">=&lt;</SPAN><SPAN style="COLOR: #000000">数据库连接</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;File&nbsp;file</SPAN><SPAN style="COLOR: #000000">=&lt;</SPAN><SPAN style="COLOR: #000000">存入数据库的文件对象</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;conn.setAutoCommit(</SPAN><SPAN style="COLOR: #0000ff">false</SPAN><SPAN style="COLOR: #000000">);&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;取消Connection对象的auto&nbsp;commit属性</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;String&nbsp;file_name</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">file.getName();<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;数据库中有一个item表，其中的file_name&nbsp;(varchar2)存储文件名，file_blob&nbsp;(blob)存储文件对象</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;String&nbsp;sql</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">INSERT&nbsp;INTO&nbsp;item&nbsp;(file_name,file_blob)&nbsp;VALUES&nbsp;('</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;file_name&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">',EMPTY_BLOB())</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;使用“EMPTY_BLOB()“成生一个空blob</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;Statement&nbsp;stmt</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">conn.createStatement();<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;count</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">stmt.executeUpdate(sql);<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;sql</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">SELECT&nbsp;file_blob&nbsp;FROM&nbsp;item&nbsp;WHERE&nbsp;iid='</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;iid&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">'&nbsp;FOR&nbsp;UPDATE</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;使用“FOR&nbsp;UPDATE”得到表的写锁</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;ResultSet&nbsp;rs</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">stmt.executeQuery(sql);<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;rs.next();<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;BLOB&nbsp;blob</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">((OracleResultSet)rs).getBLOB(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">file_blob</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;得到BLOB对象</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;OutputStream&nbsp;</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">blob.getBinaryOutputStream();&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;建立输出流</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;InputStream&nbsp;</SPAN><SPAN style="COLOR: #0000ff">in</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;FileInputStream(file);&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;建立输入流</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;size</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">blob.getBufferSize();<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[]&nbsp;buffer</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[size];&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;建立缓冲区</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;len;<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">((len</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #0000ff">in</SPAN><SPAN style="COLOR: #000000">.read(buffer))&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.write(buffer,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,len);<BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">in</SPAN><SPAN style="COLOR: #000000">.close();<BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.close();<BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;conn.commit();<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_1107_1216_Open_Image onclick="this.style.display='none'; Codehighlighter1_1107_1216_Open_Text.style.display='none'; Codehighlighter1_1107_1216_Closed_Image.style.display='inline'; Codehighlighter1_1107_1216_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_1107_1216_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1107_1216_Closed_Text.style.display='none'; Codehighlighter1_1107_1216_Open_Image.style.display='inline'; Codehighlighter1_1107_1216_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(Exception&nbsp;ex)</SPAN><SPAN id=Codehighlighter1_1107_1216_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_1107_1216_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_1114_1139_Open_Image onclick="this.style.display='none'; Codehighlighter1_1114_1139_Open_Text.style.display='none'; Codehighlighter1_1114_1139_Closed_Image.style.display='inline'; Codehighlighter1_1114_1139_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_1114_1139_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1114_1139_Closed_Text.style.display='none'; Codehighlighter1_1114_1139_Open_Image.style.display='inline'; Codehighlighter1_1114_1139_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN id=Codehighlighter1_1114_1139_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_1114_1139_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;conn.rollback();<BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_1167_1214_Open_Image onclick="this.style.display='none'; Codehighlighter1_1167_1214_Open_Text.style.display='none'; Codehighlighter1_1167_1214_Closed_Image.style.display='inline'; Codehighlighter1_1167_1214_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_1167_1214_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1167_1214_Closed_Text.style.display='none'; Codehighlighter1_1167_1214_Open_Image.style.display='inline'; Codehighlighter1_1167_1214_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(SQLException&nbsp;sqle)</SPAN><SPAN id=Codehighlighter1_1167_1214_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_1167_1214_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;System.err.println(sqle.getMessage());<BR></SPAN><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">42</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV>
<P></FONT></FONT></FONT><FONT size=2>如果要读出文件的话只需调用BLOB的getBinaryStream()生成一个输入流，再写入一个文件就行了。</FONT></P><img src ="http://www.blogjava.net/fidodido/aggbug/1145.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/fidodido/" target="_blank">^ Mustang ^</a> 2005-02-13 22:27 <a href="http://www.blogjava.net/fidodido/archive/2005/02/13/1145.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>