<?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-Free Monkey-文章分类-Open Source</title><link>http://www.blogjava.net/anymobile/category/5738.html</link><description>Make Anything Mobile!</description><language>zh-cn</language><lastBuildDate>Thu, 13 Mar 2008 03:33:07 GMT</lastBuildDate><pubDate>Thu, 13 Mar 2008 03:33:07 GMT</pubDate><ttl>60</ttl><item><title>Windows 2003下配置Apache虚拟主机</title><link>http://www.blogjava.net/anymobile/articles/122026.html</link><dc:creator>Xu Jianxiang</dc:creator><author>Xu Jianxiang</author><pubDate>Mon, 04 Jun 2007 17:55:00 GMT</pubDate><guid>http://www.blogjava.net/anymobile/articles/122026.html</guid><wfw:comment>http://www.blogjava.net/anymobile/comments/122026.html</wfw:comment><comments>http://www.blogjava.net/anymobile/articles/122026.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/anymobile/comments/commentRss/122026.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/anymobile/services/trackbacks/122026.html</trackback:ping><description><![CDATA[<p>作者：徐建祥（<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#110;&#101;&#116;&#112;&#105;&#114;&#97;&#116;&#101;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;">netpirate@gmail.com</a>）<br>时间：2007-6-4<br>网址：<a href="http://www.anymobile.org/">http://www.anymobile.org</a></p>
<p>这篇文章介绍了Apache虚拟主机的配置方法，可以看作上一篇文章（<span lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><a href="http://www.blogjava.net/anymobile/articles/112982.html"><u><font color=#800080>Windows 2003<span lang=EN-US style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><span lang=EN-US>下配置</span></span>Apache<span lang=EN-US style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><span lang=EN-US>代理</span></span>Tomcat<span lang=EN-US style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><span lang=EN-US>集群</span></span></font></u></a></span>）的后续。</p>
<p>1、需求：只有一台固网IP的服务期，要求不同的域名可以使用不同的技术，ASP、PHP、J2EE等。当然，主要以J2EE的处理为主。</p>
<p>2、解决方法：一个Apache服务（A1）充当虚拟主机，第二个Apache服务（A2）解析PHP脚本，第三个Apache服务（A3）实现Tomcat集群的代理，另外，使用IIS解析ASP程序。<br><br>结构图如下：<br><img height=303 alt="" src="http://www.blogjava.net/images/blogjava_net/anymobile/ApacheProxy.jpg" width=492 border=0><br><br>3、软件安装：Apache 2.2程序一套（D:\Apache\Apache2.2）；Tomcat 5.5 安装程序拷贝2份；IIS使用Win2003自带的。</p>
<p>4、安装步骤：<br><br>4.1 安装Apache2.2<br><br>4.2 修改A1的配置文件，conf/httpd.conf，支持虚拟主机</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">Include&nbsp;conf/extra/httpd-vhosts.conf<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>LoadModule&nbsp;proxy_module&nbsp;modules/mod_proxy.so<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>LoadModule&nbsp;proxy_http_module&nbsp;modules/mod_proxy_http.so</span></div>
<p><br>4.3 修改虚拟主机配置文件，conf/extra/httpd-vhosts.conf</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">#&nbsp;Virtual&nbsp;hosts<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">VirtualHost&nbsp;</span><span style="COLOR: #ff0000">*:80</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyPreserveHost&nbsp;On<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyPass&nbsp;/&nbsp;http://127.0.0.1:81/asp/<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyPassReverse&nbsp;/&nbsp;http://127.0.0.1:81/asp/<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;www.asp.com<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">VirtualHost</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">VirtualHost&nbsp;</span><span style="COLOR: #ff0000">*:80</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyPass&nbsp;/&nbsp;http://www.php.com:82/<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyPassReverse&nbsp;/&nbsp;http://www.php.com:82/<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;www.php.com<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">VirtualHost</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">VirtualHost&nbsp;</span><span style="COLOR: #ff0000">*:80</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyPass&nbsp;/&nbsp;http://www.j2ee.com:83/<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProxyPassReverse&nbsp;/&nbsp;http://www.j2ee.com:83/<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ServerName&nbsp;www.j2ee.com<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">VirtualHost</span><span style="COLOR: #0000ff">&gt;</span></div>
<p><br>4.4 修改A2的配置文件，conf/httpd2.conf，支持PHP<br>&nbsp;监听82端口，配置略。<br><br>4.5 修改A3的配置文件，conf/httpd3.conf，支持代理Tomcat负载均衡<br>&nbsp;监听83端口，配置略，参考上一篇文章。<br><br>4.6 修改两个Tomcat配置文件，支持集群<br>&nbsp;略，参考上一篇文章。<br><br>4.7 修改IIS，监听81端口。<br><br>4.8 开启所有的服务</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">cd&nbsp;D:\Apache\Apache2.2\bin<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>httpd.exe&nbsp;-w&nbsp;-n&nbsp;"Apache2"&nbsp;-k&nbsp;start<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>httpd.exe&nbsp;-w&nbsp;-n&nbsp;"Apache2"&nbsp;-f&nbsp;conf/httpd2.conf<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>httpd.exe&nbsp;-w&nbsp;-n&nbsp;"Apache2"&nbsp;-f&nbsp;conf/httpd3.conf<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>D:\Apache\Tomcat&nbsp;S1\bin\startup.bat<br><img src="http://www.blogjava.net/Images/OutliningIndicators/None.gif" align=top>D:\Apache\Tomcat&nbsp;S2\bin\startup.dat</span></div>
<p><br>配置完毕，下面就可以访问不同的域名了。<br><br>注：在具体的实践中，请将域名置换为相关的商业域名，另外，需要使用到host name的地方（如tomcat集群），代理转向处理地址，一定要写域名；其他情况，可以用本地ip地址加端口号的方法进行配置。<br>（全文完）</p>
<br>资料：<br><span lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><a href="http://www.blogjava.net/anymobile/articles/112982.html"><u><font color=#800080>Windows 2003<span lang=EN-US style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><span lang=EN-US>下配置</span></span>Apache<span lang=EN-US style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><span lang=EN-US>代理</span></span>Tomcat<span lang=EN-US style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><span lang=EN-US>集群</span></span></font></u></a>&nbsp;<a href="http://www.blogjava.net/anymobile/articles/112982.html">http://www.blogjava.net/anymobile/articles/112982.html</a><br>
<p class=apache>Apache HTTP Server 2.2中文手册 <a href="http://docs.huihoo.com/apache/httpd/2.2-cn/platform/windows.html">http://docs.huihoo.com/apache/httpd/2.2-cn/platform/windows.html</a></span></p>
Apache HTTP Server 2.2 VirtualHost Examples <a href="http://httpd.apache.org/docs/2.2/vhosts/examples.html">http://httpd.apache.org/docs/2.2/vhosts/examples.html</a><br><a href="http://blog.iecn.net/blog/html/do-showone-tid-1013.html"><font color=#000000>Apache下用rewrite实现动态二级域名解析</font></a>&nbsp; <a href="http://www.360doc.com/showweb/0/0/263162.aspx">http://www.360doc.com/showweb/0/0/263162.aspx</a><br>Apache服务器二级域名的完美实现（转载） <a href="http://www.360doc.com/showWeb/0/0/307889.aspx">http://www.360doc.com/showWeb/0/0/307889.aspx</a>
<img src ="http://www.blogjava.net/anymobile/aggbug/122026.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/anymobile/" target="_blank">Xu Jianxiang</a> 2007-06-05 01:55 <a href="http://www.blogjava.net/anymobile/articles/122026.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows 2003下配置Apache代理Tomcat集群</title><link>http://www.blogjava.net/anymobile/articles/112982.html</link><dc:creator>Xu Jianxiang</dc:creator><author>Xu Jianxiang</author><pubDate>Mon, 23 Apr 2007 08:56:00 GMT</pubDate><guid>http://www.blogjava.net/anymobile/articles/112982.html</guid><wfw:comment>http://www.blogjava.net/anymobile/comments/112982.html</wfw:comment><comments>http://www.blogjava.net/anymobile/articles/112982.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.blogjava.net/anymobile/comments/commentRss/112982.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/anymobile/services/trackbacks/112982.html</trackback:ping><description><![CDATA[作者：徐建祥（<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#110;&#101;&#116;&#112;&#105;&#114;&#97;&#116;&#101;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;">netpirate@gmail.com</a>）<br>时间：2007-4-19<br>网址：<a href="http://www.anymobile.org/">http://www.anymobile.org</a>
<p>索引&nbsp;</p>
<p>0、工作原理<br>1、软件准备<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.1 软件条目<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2 安装JDK<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.3 安装Tomcat<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.4 安装Apache<br>2、配置Tomcat集群<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.1 修改Tomcat默认应用<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.2 添加ROOT应用<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.3 修改server.xml<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.4 修改web.xml<br>3、配置Apache HTTP代理<br>4、优化Tomcat配置<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.1 屏蔽HTTP Connector<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.2 配置虚拟主机<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.3 配置GBK编码<br>5、测试程序&nbsp;</p>
<p>0、工作原理&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp; Apache（HTTP Server）2.2新增了代理服务器（Proxying）功能：新的代理均衡模块（mod_proxy_balancer）提供负载均衡服务；AJP 1.3（Apache JServ Protocol）替代jk/jk2等连接器与Tomcat通信。<br>&nbsp;&nbsp;&nbsp; 结合Tomcat的集群（Cluster）功能，服务器结构如下：</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=537>
            <pre><span style="COLOR: #008000">    Load Balancer</span>(Apache 2.2 Proxy)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: #008000">Cluster1</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cluster2<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp; \&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /&nbsp;&nbsp;&nbsp;&nbsp; \<br>&nbsp;<span style="COLOR: #008000">Tomcat1 Tomcat2</span>&nbsp;Tomcat3 Tomcat4</pre>
            </td>
        </tr>
    </tbody>
</table>
<p>注：绿色部分为本文采用的配置情况。<br><br>1、&nbsp;软件准备<br><br>1.1&nbsp;&nbsp;&nbsp; 软件条目<br></p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=513>
            <p>操作系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WinXP/Win2003</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=513>
            <p>JDK_5.0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://java.sun.com/javase/downloads/index_jdk5.jsp">http://java.sun.com/javase/downloads/index_jdk5.jsp</a> (MSI Installer)<br>Apache_2.2.4 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a> (MSI Installer)<br>Tomcat_5.5.23 &nbsp;&nbsp;&nbsp;&nbsp; <a href="http://tomcat.apache.org/download-55.cgi">http://tomcat.apache.org/download-55.cgi</a> (Core Zip)</p>
            </td>
        </tr>
    </tbody>
</table>
<p>&nbsp;</p>
<p>1.2&nbsp;&nbsp;&nbsp; 安装JDK<br>安装至目录 D:\Java\jdk1.5.0 下，设置JAVA_HOME/CLASSPATH/PATH，略。<br><br>1.3&nbsp;&nbsp;&nbsp; 安装Tomcat<br>解压缩Zip文件至目录 D:\Apache\Tomcat 5.5.23_S1 下；待配好后，复制到D:\Apache\Tomcat 5.5.23_S2，修改相关的端口和路径。<br><br>1.4&nbsp;&nbsp;&nbsp; 安装Apache<br>安装至目录 D:\Apache\Apache2.2 下，可在Tomcat集群配置完成后再安装。</p>
<p>2、&nbsp;配置Tomcat集群</p>
<p>2.1 修改Tomcat默认应用</p>
<p>删除$CATALINA_HOME/webapps和$CATALINA_HOME/temp目录；<br>将文件夹$CATALINA_HOME/conf/Catalina改名为Standalone。</p>
<p>2.2 添加ROOT应用</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=513>
            <p>$CATALINA_HOME/conf/Standalone/localhost/ROOT.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=513>
            <p>&lt;?xml version=&#8221;1.0&#8221; encoding=&#8221;utf-8&#8221;?&gt;<br>&lt;Context path=&#8221;&#8221; docBase=&#8221;E:\Project\wwwroot&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; displayName=&#8221;Tomcat 1&#8221; debug=&#8221;0&#8221; privileged=&#8221;true&#8221;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; antiResourceLocking=&#8221;false&#8221; antiJARLocking=&#8221;false&#8221;&gt;</p>
            <p>&nbsp;&lt;!—Default set of monitored resources --&gt;</p>
            <p>&nbsp;&lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;</p>
            <p>&lt;/Context&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p><br>2.3 修改server.xml</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=513 colSpan=4>
            <p>$CATALINA_HOME/conf/server.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=228>
            <p align=center>操作步骤</p>
            </td>
            <td vAlign=top width=96>
            <p align=center>默认</p>
            </td>
            <td vAlign=top width=96>
            <p align=center>Tomcat 1</p>
            </td>
            <td vAlign=top width=93>
            <p align=center>Tomcat 2</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=228>
            <p>2.3.1 修改Server端口</p>
            </td>
            <td vAlign=top width=96>
            <p>8005</p>
            </td>
            <td vAlign=top width=96>
            <p>10005</p>
            </td>
            <td vAlign=top width=93>
            <p>20005</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=228>
            <p>2.3.2 修改AJP Connector端口</p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp; Apache JServ Protocol 1.3</p>
            </td>
            <td vAlign=top width=96>
            <p>8009</p>
            </td>
            <td vAlign=top width=96>
            <p>10009</p>
            </td>
            <td vAlign=top width=93>
            <p>20009</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=228>
            <p>2.3.3 修改HTTPConnector端口</p>
            </td>
            <td vAlign=top width=96>
            <p>8080</p>
            </td>
            <td vAlign=top width=96>
            <p>10001</p>
            </td>
            <td vAlign=top width=93>
            <p>20001</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=228>
            <p>2.3.4 修改redirectPort端口</p>
            </td>
            <td vAlign=top width=96>
            <p>8443</p>
            </td>
            <td vAlign=top width=96>
            <p>10043</p>
            </td>
            <td vAlign=top width=93>
            <p>20043</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=513 colSpan=4>
            <p>2.3.5 屏蔽Catalina，打开Standalone，并修改jvmRoute的值为Tomcat1/Tomcat2</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=228>
            <p>2.3.6打开Cluster，修改tcpListenPort</p>
            </td>
            <td vAlign=top width=96>
            <p>4001</p>
            </td>
            <td vAlign=top width=96>
            <p>10011</p>
            </td>
            <td vAlign=top width=93>
            <p>20011</p>
            </td>
        </tr>
    </tbody>
</table>
<p>2.4 修改web.xml&nbsp;</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=513>
            <p>$CATALINA_HOME/conf/web.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=513>
            <p>（添加）&lt;distributable/&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;或者</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=513>
            <p>$CATALINA_HOME/conf/Standalone/*/ROOT.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=513>
            <p>（设置）&lt;Context distributable="true" &#8230;/&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;设置集群，session共享。</p>
<p>3、&nbsp;配置Apache HTTP代理，实现负载均衡</p>
<p>有三种方法实现Tomcat的负载均衡：</p>
<p>a．&nbsp;使用JK本地连接器（Tomcat-Apache通信插件，JServ-&gt;JK-&gt;JK2-&gt;AJServP）；<br>b．&nbsp;使用2.x版本的Aache HTTP服务器的代理模块；<br>c．&nbsp;使用Tomcat的blancer web应用。</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=537>
            <p>$APACHE_HOME/conf/httpd.conf</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=537>
            <p># 添加下面这段代码<br>LoadModule proxy_module modules/mod_proxy.so<br>LoadModule proxy_ajp_module modules/mod_proxy_ajp.so<br>LoadModule proxy_balancer_module modules/mod_proxy_balancer.so<br>LoadModule proxy_http_module modules/mod_proxy_http.so<br><br>ProxyRequests Off<br><br>ProxyPass / balancer://myCluster/<br>&lt;Proxy balancer://myCluster/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BalancerMember ajp://localhost:10009 route=Tomcat1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BalancerMember ajp://localhost:20009 route=Tomcat2<br>&lt;/Proxy&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 至此，Apache和Tomcat已经安装、配置完毕，可以依次运行两个Tomcat（/bin/startup.bat）和Apache程序（Apache Monitor）。<br><br>注：<br>(1) 若系统设置了系统变量CATALINA_HOME，需修改/bin/startup.bat，屏蔽下面的代码：<br>#if not "%CATALINA_HOME%" == "" goto gotHome<br>(2) Apache只是一个代理服务器，所有的请求全部转至Tomcat处理，故启用ROOT应用。<br><br>4、&nbsp;优化Tomcat配置<br><br>4.1 屏蔽HTTP Connector</p>
<p>&nbsp;</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=513>
            <p>&lt;!-- Define a non-SSL HTTP/1.1 Connector on port 8080 --&gt;<br>&lt;!--<br>&lt;Connector port="8080" &#8230;/&gt;<br>--&gt;</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=513>
            <p>&lt;!-- Define a SSL HTTP/1.1 Connector on port 8443 --&gt;<br>&lt;!--<br>&lt;Connector port="8443" &#8230;/&gt;<br>--&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p><br>4.2 配置虚拟主机<br><br>4.2.1 编辑server.xml的Engine，添加Host信息</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=477>
            <p>$CATALINA_HOME/conf/server.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=477>
            <p>&lt;Engine name="Standalone" defaultHost="localhost" jvmRoute="Tomcat1"&gt;</p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Host name="localhost" appBase="webapps" &#8230;&gt;&#8230; &#8230;&lt;/Host&gt;</p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Host name="www.site.com" appBase="webapps/www.site.com"/&gt;</p>
            <p>&nbsp;&nbsp;&nbsp; &lt;Host name="www.site.net" appBase="webapps/www.site.net"/&gt;</p>
            <p>&lt;/Engine&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p>4.2.2 创建虚拟主机对应的Webapp目录</p>
<p>&nbsp;</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=477>
            <p>$CATALINA_HOME/webapps/www.site.com</p>
            <p>$CATALINA_HOME/webapps/www.site.net</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=477>
            <p>均为空目录</p>
            </td>
        </tr>
    </tbody>
</table>
<p>4.2.3 创建虚拟主机&nbsp;&nbsp;&nbsp; </p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=477>
            <p>$CATALINA_HOME/conf/Standalone/www.site.com/ROOT.xml</p>
            <p>$CATALINA_HOME/conf/Standalone/www.site.net/ROOT.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=477>
            <p>&lt;?xml version="1.0" encoding="utf-8"?&gt;</p>
            <p>&lt;Context path="" docBase="E:\Project\{site name}" &#8230;&gt;</p>
            <p>&nbsp;&lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;</p>
            <p>&lt;/Context&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p>另一个Tomcat Node也做类似的修改，并分别重启两个Tomcat。<br><br>4.3 配置GBK编码</p>
<p>&nbsp;</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=513>
            <p>$CATALINA_HOME/conf/server.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=513>
            <p>&nbsp;&nbsp;&nbsp; &lt;!-- Define an AJP 1.3 Connector on port 10009 --&gt;</p>
            <p>&nbsp;&nbsp;&nbsp; &lt;Connector port="10009" URIEncoding="GBK" </p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="false" redirectPort="10443" protocol="AJP/1.3" /&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p><br>5、测试程序&nbsp;</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=561>
            <p>init.jsp</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=561>
            <p>&lt;%</p>
            <p>session.setAttribute("name",request.getParameter("name"));</p>
            <p>out.println("success!" + session.getId());</p>
            <p>%&gt;</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=561>
            <p>testRoute.jsp</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=561>
            <p>&lt;%</p>
            <p>String test = session.getId() + " - " + session.getAttribute("name");</p>
            <p>System.out.println( new java.util.Date() + ":" + test);</p>
            <p>out.println( test );</p>
            <p>%&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p>访问 <a href="http://localhost/init.jsp?name=HAHA">http://localhost/init.jsp?name=HAHA</a>（只须执行一次）<br>访问 <a href="http://localhost/testRoute.jsp">http://localhost/testRoute.jsp</a><br>访问多次就可以发现，两个Tomat服务器是均衡的，且session共享。<br>&nbsp;<img src="http://www.blogjava.net/images/blogjava_net/anymobile/8280/o_Tomcat%20Cluster%201.JPG" border=0></p>
<p>另外，还可以设置路由JSESSIONID</p>
<table cellSpacing=0 cellPadding=0 border=1>
    <tbody>
        <tr>
            <td vAlign=top width=561>
            <p>$CATALINA_HOME/conf/server.xml</p>
            </td>
        </tr>
        <tr>
            <td vAlign=top width=561>
            <p>&lt;!-- sessionIdAttribute default attribute name is</p>
            <p>&nbsp;org.apache.catalina.cluster.session.JvmRouteOrignalSessionID.</p>
            <p>&nbsp;JSESSIONID.{orignal node id} &#224;</p>
            <p>&lt;Valve className="org.apache.catalina.cluster.session.JvmRouteBinderValve" </p>
            <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;enabled="true" sessionIdAttribute="takeoverSessionid"/&gt;</p>
            <p>&lt;ClusterListener className="org.apache.catalina.cluster.session.JvmRouteSessionIDBinderListener" /&gt;</p>
            </td>
        </tr>
    </tbody>
</table>
<p>&nbsp;<img height=296 src="http://www.blogjava.net/images/blogjava_net/anymobile/8280/o_Tomcat%20Cluster%202.JPG" width=703 border=0><br><br>参考资料<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Apache Proxy Module&nbsp;&nbsp;&nbsp; <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">http://httpd.apache.org/docs/2.2/mod/mod_proxy.html</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Apache Balancer Module&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html">http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tomcat 5.5 Load Balancer&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://tomcat.apache.org/tomcat-5.5-doc/balancer-howto.html">http://tomcat.apache.org/tomcat-5.5-doc/balancer-howto.html</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tomcat 5.5 Clustering/Session Replication&nbsp;&nbsp; <a href="http://tomcat.apache.org/.../cluster-howto.html">http://tomcat.apache.org/.../cluster-howto.html</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Apache Tomcat 5.5 Proxy&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html">http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html</a></p>
（全文完） <br>[补][推荐]Apache HTTP Server 与 Tomcat 的三种连接方式介绍(刘 冬@IBM) <a href="http://www-128.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/index.html">http://www-128.ibm.com/developerworks/cn/opensource/os-lo-apache-tomcat/index.html</a> <img src ="http://www.blogjava.net/anymobile/aggbug/112982.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/anymobile/" target="_blank">Xu Jianxiang</a> 2007-04-23 16:56 <a href="http://www.blogjava.net/anymobile/articles/112982.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts FAQ</title><link>http://www.blogjava.net/anymobile/articles/98791.html</link><dc:creator>Xu Jianxiang</dc:creator><author>Xu Jianxiang</author><pubDate>Thu, 08 Feb 2007 07:53:00 GMT</pubDate><guid>http://www.blogjava.net/anymobile/articles/98791.html</guid><wfw:comment>http://www.blogjava.net/anymobile/comments/98791.html</wfw:comment><comments>http://www.blogjava.net/anymobile/articles/98791.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/anymobile/comments/commentRss/98791.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/anymobile/services/trackbacks/98791.html</trackback:ping><description><![CDATA[
		<p>
		</p>
		<p>1/ 不支持嵌套标签<br />   如按钮的名称就不可以直接读取配置，另外标签的默认值是在struts类中写死了，如submit按</p>
		<p>钮的默认值就是"submit"<br />   &lt;html:input name="keywords" values="&lt;bean:message value="m_k"&gt;"/&gt;</p>
		<p>2/ radio按钮设置默认</p>
		<p>   2.1/ 在form构造函数中设置默认值<br />   2.2/ 在form的reset方法中设置默认值<br />   2.3/ 使用js脚本设置默认值<br />&lt;script&gt;<br /> document.all("sex")[0].checked=true;//第一个radio选中<br />&lt;/script&gt;</p>
		<p>3/ 配置资源文件</p>
		<p>   3.1/ web.xml(from 1.1)<br />   3.2/ struts-config.xml(from 1.2)</p>
		<p>   web.xml中的配置优先，解决多配置文件的方法：别名bundle(since 1.2)，建议使用3.2。</p>
		<p>   a. web.xml<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">   </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">web-app</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">servlet</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">servlet-name</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">action</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">servlet-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" />       </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">servlet-class</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">org.apache.struts.action.ActionServlet</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">servlet-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">init-param</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">param-name</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<font color="#0000ff">application</font>
				</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param-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" />         </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param-value</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<font color="#0000ff">org.anymobile.test.struts.ApplicationResources</font>
				</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param-value</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">init-param</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">init-param</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">param-name</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">config</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param-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" />         </span>
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">param-value</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">/WEB-INF/struts-config.xml</span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">param-value</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">init-param</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />       <img src="http://www.blogjava.net/images/dot.gif" /> <img src="http://www.blogjava.net/images/dot.gif" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">servlet</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     <img src="http://www.blogjava.net/images/dot.gif" /> <img src="http://www.blogjava.net/images/dot.gif" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">&lt;/</span>
				<span style="COLOR: #800000">web-app</span>
				<span style="COLOR: #0000ff">&gt;</span>
		</div>
		<p>   b. struts-config.xml，如果web.xml配置了资源文件，可以加个资源文件，内容为空</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: #0000ff">&lt;</span>
				<span style="COLOR: #800000">message-resources </span>
				<span style="COLOR: #ff0000">parameter</span>
				<span style="COLOR: #0000ff">="org.anymobile.test.struts.ApplicationResources2"</span>
				<span style="COLOR: #ff0000"> </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">message-resources </span>
				<span style="COLOR: #ff0000">key</span>
				<span style="COLOR: #0000ff">="bundle2"</span>
				<span style="COLOR: #ff0000"> parameter</span>
				<span style="COLOR: #0000ff">="org.anymobile.test.struts.ApplicationResources2"</span>
				<span style="COLOR: #ff0000"> </span>
				<span style="COLOR: #0000ff">/&gt;</span>
		</div>
		<p>   c. /org/anymobile/test/struts/ApplicationResources.properties<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">
						<font color="#0000ff">hello.message</font> = Hello are you?</span>
		</div>
		<p>   d. java 程序</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">ActionMessage err </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> ActionMessage( </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<font color="#0000ff">bundle2.</font>hello.message</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> );</span>
		</div>
		<p>   e. jsp 程序</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">&lt;</span>
				<span style="COLOR: #000000">bean:message bundle</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<font color="#0000ff">bundle2</font>
				</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> key</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">hello.message</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </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">html:errors bundle</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<font color="#0000ff">bundle2</font>
				</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/&gt;</span>
		</div>
		<p>4/ 与 gnujaxp.jar 冲突<br />   Tomcat启动报错；Web页面可以显示；提交后，*.do会报错。<br />   使用JFreeChart开源软件时，只添加jcommon.jar，jfreechart.jar两个包。</p>
		<p>5/ checkbox<br />   private boolean syaken = true;(default true,false)<br />   &lt;html:checkbox property="syaken"/&gt;<br />   &lt;input type="hidden" name="syaken" value="false"&gt;</p>
		<p>   private String type;(default 0,1)<br />   &lt;html:checkbox property="syaken"  value="1"/&gt;</p>
<img src ="http://www.blogjava.net/anymobile/aggbug/98791.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/anymobile/" target="_blank">Xu Jianxiang</a> 2007-02-08 15:53 <a href="http://www.blogjava.net/anymobile/articles/98791.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate FAQ</title><link>http://www.blogjava.net/anymobile/articles/98790.html</link><dc:creator>Xu Jianxiang</dc:creator><author>Xu Jianxiang</author><pubDate>Thu, 08 Feb 2007 07:51:00 GMT</pubDate><guid>http://www.blogjava.net/anymobile/articles/98790.html</guid><wfw:comment>http://www.blogjava.net/anymobile/comments/98790.html</wfw:comment><comments>http://www.blogjava.net/anymobile/articles/98790.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/anymobile/comments/commentRss/98790.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/anymobile/services/trackbacks/98790.html</trackback:ping><description><![CDATA[<p>1/ 数据库驱动</p>
<p>&nbsp;&nbsp; 1.1/ Oracle<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jdbc驱动需要注意版本，class111.jar；o_jdbc.jar。<br>&nbsp;&nbsp; 1.2/ MS SQL Server<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注意版本和网络配置（tcp和管道的权限）。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 官方驱动：2000，3个jar包；2005，一个jar包。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jrds驱动：评价普遍比官方的好，注意各个版本。<br>&nbsp;&nbsp; 1.3/ MySQL</p>
<p>2/ 数据库连接/session</p>
<p>&nbsp;&nbsp; 2.1/ hibernate.cfg.xml配置jdbc驱动<br>&nbsp;&nbsp; 2.2/ hibernate.cfg.xml配置datasource<br>&nbsp;&nbsp; 2.3/ 在获取session时加载Connection<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struts的datasource<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; web server的datasource<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbcp的datasource</p>
<p>3/ 事务Transaction 与 commit<br>&nbsp; <br>&nbsp;&nbsp; 一次事务只可以提交一次，多次提交会报错。<br>&nbsp;&nbsp; javax.servlet.ServletException: JDBC commit failed</p>
<p>4/ 一张表转换成了2个对象，修正为一个对象</p>
<p>&nbsp;&nbsp; 4.1 修改*.hbm.xml，去除composite-id标签，将主键对应的key-property改为id，其它key-property改为property；<br>&nbsp;&nbsp; 4.2 删除*.java和Abstract*.java，将*Id.java和Abstract*Id.java分别重构为*.java和Abstract*.java；<br>&nbsp;&nbsp; 4.3 修改*DAO.jar，将findById的参数修正为主键的类型，注意与*.hbm.xml匹配。<br><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: #0000ff">&lt;</span> <span style="COLOR: #800000">hibernate-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;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">class&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="com.inc.xschool.entity.PositionInfo"</span> <span style="COLOR: #ff0000">&nbsp;table</span> <span style="COLOR: #0000ff">="POSITION_INFO"</span> <span style="COLOR: #ff0000">&nbsp;schema</span> <span style="COLOR: #0000ff">="dbo"</span> <span style="COLOR: #ff0000">&nbsp;catalog</span> <span style="COLOR: #0000ff">="xschool"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">composite-id&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="id"</span> <span style="COLOR: #ff0000">&nbsp;class</span> <span style="COLOR: #0000ff">="com.inc.xschool.entity.PositionInfoId"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">key-property&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="positionId"</span> <span style="COLOR: #ff0000">&nbsp;type</span> <span style="COLOR: #0000ff">="java.lang.Long"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">column&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="POSITION_ID"</span> <span style="COLOR: #ff0000">&nbsp;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;/</span> <span style="COLOR: #800000">key-property</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">key-property&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="positionName"</span> <span style="COLOR: #ff0000">&nbsp;type</span> <span style="COLOR: #0000ff">="java.lang.String"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">column&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="POSITION_NAME"</span> <span style="COLOR: #ff0000">&nbsp;length</span> <span style="COLOR: #0000ff">="50"</span> <span style="COLOR: #ff0000">&nbsp;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;/</span> <span style="COLOR: #800000">key-property</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">key-property&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="custId"</span> <span style="COLOR: #ff0000">&nbsp;type</span> <span style="COLOR: #0000ff">="java.lang.String"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;</span> <span style="COLOR: #800000">column&nbsp;</span> <span style="COLOR: #ff0000">name</span> <span style="COLOR: #0000ff">="CUST_ID"</span> <span style="COLOR: #ff0000">&nbsp;length</span> <span style="COLOR: #0000ff">="50"</span> <span style="COLOR: #ff0000">&nbsp;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;/</span> <span style="COLOR: #800000">key-property</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;/</span> <span style="COLOR: #800000">composite-id</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;&nbsp;&nbsp;</span> <span style="COLOR: #0000ff">&lt;/</span> <span style="COLOR: #800000">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">hibernate-mapping</span> <span style="COLOR: #0000ff">&gt;</span> </div>
<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">hibernate-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;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">class&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="com.inc.xschool.entity.PositionInfo"</span><span style="COLOR: #ff0000">&nbsp;table</span><span style="COLOR: #0000ff">="POSITION_INFO"</span><span style="COLOR: #ff0000">&nbsp;schema</span><span style="COLOR: #0000ff">="dbo"</span><span style="COLOR: #ff0000">&nbsp;catalog</span><span style="COLOR: #0000ff">="xschool"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">id&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="positionId"</span><span style="COLOR: #ff0000">&nbsp;type</span><span style="COLOR: #0000ff">="java.lang.Long"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">column&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="POSITION_ID"</span><span style="COLOR: #ff0000">&nbsp;precision</span><span style="COLOR: #0000ff">="2"</span><span style="COLOR: #ff0000">&nbsp;scale</span><span style="COLOR: #0000ff">="0"</span><span style="COLOR: #ff0000">&nbsp;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">generator&nbsp;</span><span style="COLOR: #ff0000">class</span><span style="COLOR: #0000ff">="assigned"</span><span style="COLOR: #0000ff">&gt;&lt;/</span><span style="COLOR: #800000">generator</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">id</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">property&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="positionName"</span><span style="COLOR: #ff0000">&nbsp;type</span><span style="COLOR: #0000ff">="java.lang.String"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">column&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="POSITION_NAME"</span><span style="COLOR: #ff0000">&nbsp;length</span><span style="COLOR: #0000ff">="50"</span><span style="COLOR: #ff0000">&nbsp;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">property</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">property&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="custId"</span><span style="COLOR: #ff0000">&nbsp;type</span><span style="COLOR: #0000ff">="java.lang.String"</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;</span><span style="COLOR: #800000">column&nbsp;</span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="CUST_ID"</span><span style="COLOR: #ff0000">&nbsp;length</span><span style="COLOR: #0000ff">="50"</span><span style="COLOR: #ff0000">&nbsp;</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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">property</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;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">&lt;/</span><span style="COLOR: #800000">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">hibernate-mapping</span><span style="COLOR: #0000ff">&gt;</span></div>
<p>5/ 递增字段（整型）<br>&nbsp;&nbsp; 5.1 Oracle&nbsp;&nbsp;&lt;generator class="sequence"&gt;SEQ_NAME&lt;/generator&gt;<br>&nbsp;&nbsp; 5.2 MySQL&nbsp;&nbsp;&lt;generator class="increment"/&gt;<br>&nbsp;&nbsp; 5.3 SQL SERVER&nbsp;&lt;generator class="identity"/&gt;</p>
<p>6/ MS SQL SERVER Exception</p>
<p>6.1 [Microsoft][SQLServer 2000 Driver for JDBC]Underlying input stream returned zero bytes<br>jdbc bug,text字段的值设为了空或''，改成' '即可，2005中也许修正此bug。</p>
<p>6.2 [Microsoft][SQLServer 2000 Driver for JDBC]Can't start a cloned connection while in manual transaction mode. <br>在手工事务模式 (AutoCommit=false) 下，如果使用直接 (SelectMethod=direct) 模式，当您尝试对使用 JDBC 驱动程序的 SQL Server 数据库执行多个语句时，将会出现此问题。直接模式是该驱动程序的默认模式。 <br>url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=whm;SelectMethod=cursor</p>
<p>6.3 [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.<br>&nbsp;&nbsp;&nbsp; com.microsoft.sqlserver.jdbc.SQLServerException: 到主机&nbsp; 的 TCP/IP 连接失败。 </p>
<p>客户端：10.170.10.2; WinXP SP2; SQL Server 2000(SP4)<br>服务端：10.170.10.3; Win2003 Server; SQL Server 2000(SP4)<br><br>1/ Microsoft SQL Server 2000 Driver for JDBC(Service Pack 1)<br>msbase.jar;mssqlserver.jar;msutil.jar</p>
<p>Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();<br>String url&nbsp; = "jdbc:microsoft:sqlserver://10.170.10.3:1433;DatabaseName=xschool";</p>
<p>java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.<br>&nbsp;at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)<br>&nbsp;at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)<br>&nbsp;at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)<br>&nbsp;at com.microsoft.jdbc.sqlserver.tds.TDSConnection.&lt;init&gt;(Unknown Source)<br>&nbsp;at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)<br>&nbsp;at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)<br>&nbsp;at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)<br>&nbsp;at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)<br>&nbsp;at java.sql.DriverManager.getConnection(DriverManager.java:512)<br>&nbsp;at java.sql.DriverManager.getConnection(DriverManager.java:171)<br>&nbsp;at com.inc.xchool.test.TestJDBC.main(TestJDBC.java:31)</p>
<p>2/ Microsoft SQL Server 2005 JDBC Driver<br>sqljdbc.jar</p>
<p>Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();<br>String url&nbsp; = "jdbc:sqlserver://10.170.10.3:1433;DatabaseName=xschool";</p>
<p>com.microsoft.sqlserver.jdbc.SQLServerException: 到主机&nbsp; 的 TCP/IP 连接失败。 java.net.ConnectException: Connection timed out: connect<br>&nbsp;at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)<br>&nbsp;at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)<br>&nbsp;at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)<br>&nbsp;at java.sql.DriverManager.getConnection(DriverManager.java:512)<br>&nbsp;at java.sql.DriverManager.getConnection(DriverManager.java:171)<br>&nbsp;at com.inc.xchool.test.TestJDBC.main(TestJDBC.java:34)</p>
<p>3/ Win的数据源(ODBC)，系统DSN<br>Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();<br>可以建立连接</p>
<p>解决方法：在10.3的防火墙设置中开通1433的TCP权限。<br><img alt="SQL SERVER TCP 1433" src="http://www.blogjava.net/images/blogjava_net/anymobile/8280/o_tcp1433.jpg"><br><br>6.4 org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case: /ok/hibernate.reveng.xml.<br>状况：新建了2个web项目，一个叫ok，一个叫okadmin，都添加了hibernate关联，后者反转数据库结构的时候，eclipse在.log中留下以上的log。<br>解决方法：临时remove另外一个项目。<br><br>6.5 ORA-01461 can bind a LONG value only for insert into a LONG column<br>状况：JDBC驱动与连接的Oracle数据库版本不一致。<br>解决方法：置换JDBC驱动为Oracle系统自带的。</p>
<img src ="http://www.blogjava.net/anymobile/aggbug/98790.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/anymobile/" target="_blank">Xu Jianxiang</a> 2007-02-08 15:51 <a href="http://www.blogjava.net/anymobile/articles/98790.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>基于Struts和Hibernate的轻量级J2EE应用</title><link>http://www.blogjava.net/anymobile/articles/91870.html</link><dc:creator>Xu Jianxiang</dc:creator><author>Xu Jianxiang</author><pubDate>Thu, 04 Jan 2007 16:35:00 GMT</pubDate><guid>http://www.blogjava.net/anymobile/articles/91870.html</guid><wfw:comment>http://www.blogjava.net/anymobile/comments/91870.html</wfw:comment><comments>http://www.blogjava.net/anymobile/articles/91870.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/anymobile/comments/commentRss/91870.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/anymobile/services/trackbacks/91870.html</trackback:ping><description><![CDATA[
		<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
				<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">作者：徐建祥（</span>
						<span lang="EN-US" style="COLOR: #4b4b4b">
								<a href="mailto:netpirate@gmail.com">
										<font face="Times New Roman" color="#1a8bc8">netpirate@gmail.com</font>
								</a>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span>
				</p>
				<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">时间：</span>
						<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /?>
						<st1:chsdate w:st="on" isrocdate="False" islunardate="False" day="3" month="1" year="2007">
								<span lang="EN-US">
										<font face="Times New Roman">2007-01-03</font>
								</span>
						</st1:chsdate>
				</p>
				<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
						<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">网址：</span>
						<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #4b4b4b; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">
								<a href="http://www.anymobile.org/">http://www.anymobile.org</a>
						</span>
				</p>
		</span>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt">
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">1、<span style="FONT: 7pt 'Times New Roman'"></span></span>
						</span>
				</b>
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">项目介绍</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">××××项目是基于……（背景，范畴，术语）</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt">
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">2、<span style="FONT: 7pt 'Times New Roman'"></span></span>
						</span>
				</b>
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">系统设计</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为了降低系统的耦合性，提高系统的实用性和灵活性，对系统的页面逻辑、业务逻辑和数据逻辑进行分层。集合当前的</span>
				<span lang="EN-US">Web</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">技术，在</span>
				<span lang="EN-US">Java</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">环境下，采用实现了</span>
				<span lang="EN-US">MVC</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模式的</span>
				<span lang="EN-US">Struts</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和实现了数据持久化的</span>
				<span lang="EN-US">Hibernate</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的开源框架组合，</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
				<span lang="EN-US">Hibernate</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中整合</span>
				<span lang="EN-US">EhCache</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，对数据进行缓存。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">本系统的体系结构如下：</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" align="center">
				<span lang="EN-US">
						<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /?>
						<v:shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600">
								<v:stroke joinstyle="miter">
								</v:stroke>
								<v:formulas>
										<v:f eqn="if lineDrawn pixelLineWidth 0">
										</v:f>
										<v:f eqn="sum @0 1 0">
										</v:f>
										<v:f eqn="sum 0 0 @1">
										</v:f>
										<v:f eqn="prod @2 1 2">
										</v:f>
										<v:f eqn="prod @3 21600 pixelWidth">
										</v:f>
										<v:f eqn="prod @3 21600 pixelHeight">
										</v:f>
										<v:f eqn="sum @0 0 1">
										</v:f>
										<v:f eqn="prod @6 1 2">
										</v:f>
										<v:f eqn="prod @7 21600 pixelWidth">
										</v:f>
										<v:f eqn="sum @8 21600 0">
										</v:f>
										<v:f eqn="prod @7 21600 pixelHeight">
										</v:f>
										<v:f eqn="sum @10 21600 0">
										</v:f>
								</v:formulas>
								<v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f">
								</v:path>
								<o:lock aspectratio="t" v:ext="edit">
								</o:lock>
						</v:shapetype>
						<img src="http://www.blogjava.net/images/blogjava_net/anymobile/8280/o_StrutsHibernate.gif" />
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其中，应用表示层基于</span>
				<span lang="EN-US">Struts</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">框架，业务逻辑层包含了供应用程序调用的业务逻辑规则，以帮助应用程序完成业务操作，数据持久层基于</span>
				<span lang="EN-US">Hibernate</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">框架，采用 <span lang="EN-US">DAO</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span><span lang="EN-US">Data Access Object</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）模式操作数据库，</span>应用服务器采用</span>
				<span lang="EN-US">Tomcat</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt">
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">3、<span style="FONT: 7pt 'Times New Roman'"></span></span>
						</span>
				</b>
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">详细设计</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">本系统具有多个模块，但各个模块的基本设计原理相同，下面将逐个描述。</span>
				<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">……</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt">
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">4、<span style="FONT: 7pt 'Times New Roman'"></span></span>
						</span>
				</b>
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数据库设计</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">……</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt">
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">5、<span style="FONT: 7pt 'Times New Roman'"></span></span>
						</span>
				</b>
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开发示例</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">5.1 </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开发环境</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>WinXP</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>JDK <st1:chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False">1.4.2</st1:chsdate></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Eclipse <st1:chsdate w:st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False">3.2.1</st1:chsdate> SDK</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">MyEclipse 5.0GA</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（</span>
				<span lang="EN-US">Struts 1.2</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">；</span>
				<span lang="EN-US">Hibernate 3.1</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">Tomcat 5.5</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">5.2 </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">新建</span>
				<span lang="EN-US">Web Project</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>File-&gt;New Project-&gt;MyEclipse-&gt;J2EE Projects-&gt;Web Project</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">5.3 </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立</span>
				<span lang="EN-US">Struts</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关联</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>MyEclipse-&gt;Add Struts Capabilities</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">5.4 </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立数据库浏览</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Window-&gt; Preferences-&gt;MyEclipse-&gt;Database Explorer-&gt;New Driver</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Window-&gt;Customize Perspective-&gt;Commands</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，选上</span>
				<span lang="EN-US">Profile</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Profile</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">窗口，</span>
				<span lang="EN-US">Connection it</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">5.5 </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立</span>
				<span lang="EN-US">Hibernate</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关联</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>MyEclipse-&gt;Add Hibernate Capabilities</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">5.6 </span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配置应用服务器</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Window-&gt; Preferences-&gt; Application Server-&gt;Tomcat 5</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，选择</span>
				<span lang="EN-US">Enable</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，浏览</span>
				<span lang="EN-US">Tomcat</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的安装目录，浏览</span>
				<span lang="EN-US">JDK</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的安装目录</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; mso-para-margin-left: 2.0gd">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">右键点击</span>
				<span lang="EN-US">Project</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span>
				<span lang="EN-US">MyEclipse-&gt; Add and Remove Project Deployment</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，点击</span>
				<span lang="EN-US">Add</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span>
				<span lang="EN-US">Server</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">选择</span>
				<span lang="EN-US">Tomcat 5</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</span>
				<span lang="EN-US">Finish</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt; mso-para-margin-left: 2.0gd">
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">点击</span>
				<span lang="EN-US">Run server</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，切换到</span>
				<span lang="EN-US">Web Browser</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">窗口，就可以访问了。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<o:p> <img src="http://www.blogjava.net/images/blogjava_net/anymobile/8280/o_StrutsHibernateEclipse.jpg" /><br /></o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">参考文档</span>
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Eclipse-&gt;Help-&gt;Help Contents-&gt;<st1:place w:st="on"><st1:placename w:st="on">MyEclipse</st1:placename><st1:placename w:st="on">Learning</st1:placename><st1:placetype w:st="on">Center</st1:placetype></st1:place>-&gt;J2EE Application Development-&gt;Getting Started-&gt;Struts Development</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Eclipse-&gt;Help-&gt;Help Contents-&gt;<st1:place w:st="on"><st1:placename w:st="on">MyEclipse</st1:placename><st1:placename w:st="on">Learning</st1:placename><st1:placetype w:st="on">Center</st1:placetype></st1:place>-&gt;Spring/Hibernate Development-&gt;Getting Started-&gt;Hibernate Development</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Struts-Hibernate-Integration-Tutorial http://www.laliluna.de/download/struts-hibernate-integration-tutorial-en.pdf</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt">
		</p>&lt;全文完&gt;<img src ="http://www.blogjava.net/anymobile/aggbug/91870.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/anymobile/" target="_blank">Xu Jianxiang</a> 2007-01-05 00:35 <a href="http://www.blogjava.net/anymobile/articles/91870.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Contributing to Eclipse（2）－－Eclipse 插件</title><link>http://www.blogjava.net/anymobile/articles/64934.html</link><dc:creator>Xu Jianxiang</dc:creator><author>Xu Jianxiang</author><pubDate>Mon, 21 Aug 2006 17:38:00 GMT</pubDate><guid>http://www.blogjava.net/anymobile/articles/64934.html</guid><wfw:comment>http://www.blogjava.net/anymobile/comments/64934.html</wfw:comment><comments>http://www.blogjava.net/anymobile/articles/64934.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/anymobile/comments/commentRss/64934.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/anymobile/services/trackbacks/64934.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US" style="FONT-SIZE: 12pt">1、Eclipse </span>
				</b>
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">法则(Eclipse Rule)</span>
				</b>
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US" style="FONT-SIZE: 12pt">
								<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">扩展者(</span>
						<span lang="EN-US">Extender)</span>
				</b>
				<b style="mso-bidi-font-weight: normal">
				</b>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">――添加插件</span>
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">贡献法则（</span>
				<span lang="EN-US">Contribution Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：一切皆是贡献。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">遵循法则（</span>
				<span lang="EN-US">Conformance Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：插件必须遵循预期的接口。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共享法则（</span>
				<span lang="EN-US">Sharing Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：增加，不要取代。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有样学样法则（</span>
				<span lang="EN-US">Monkey See/Monkey Do Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：遇到问题时，首先复制类似插件的结构。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相关性法则（</span>
				<span lang="EN-US">Relevance Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：只有在操作有可能成功时菜显示你所贡献的操作。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">整合法则（</span>
				<span lang="EN-US">Integration Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：要整合，不要分裂。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">责任法则（</span>
				<span lang="EN-US">Responsibility Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：明确指出你所开发的插件时问题的源头。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">针对</span>
				<span lang="EN-US">API</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">契约编程法则（</span>
				<span lang="EN-US">Program to API Contract Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：首先检查</span>
				<span lang="EN-US">Eclipse API</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">契约，然后针对契约编程。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>Other</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">法则（</span>
				<span lang="EN-US">Other Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：让用户可以选择所有东西，但把那些通常不用于当前视角的选项放在</span>
				<span lang="EN-US">Other…</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对话框中。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>IResource</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">适配法则（</span>
				<span lang="EN-US">Adapt to IResource Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：应该尽量为领域对象定义</span>
				<span lang="EN-US">IResource</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">适配器。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分层法则（</span>
				<span lang="EN-US">Strata Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：将语言无关的功能与特定于具体语言的功能分开，将核心性能与</span>
				<span lang="EN-US">UI</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分开。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用户连贯性法则（</span>
				<span lang="EN-US">User Continuity Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：在多次会话之间，应该保持</span>
				<span lang="EN-US">UI</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">状态一致。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">促成者(</span>
						<span lang="EN-US">Enabler</span> </b>
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">)</span>
				</b>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">――发布扩展点</span>
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US">
								<span style="mso-tab-count: 1">       </span>
						</span>
				</b>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">邀请法则（</span>
				<span lang="EN-US">Invitation Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：尽可能的邀请别人为你的作品作出贡献，发布扩展点。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">懒加载法则（</span>
				<span lang="EN-US">Lazy Loading Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：只有在真正需要的时候才加载插件。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">安全平台法则（</span>
				<span lang="EN-US">Safe Platform Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：作为扩展点的提供者，你必须保护好自己，不要让扩展者的误操作给你造成损失。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">公平竞争法则（</span>
				<span lang="EN-US">Fair Play Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：所有使用者遵守同样的游戏规则，包括我自己。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">明确扩展法则（</span>
				<span lang="EN-US">Explicit Extension Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：明确说明平台的什么地方可供扩展。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">发散性法则（</span>
				<span lang="EN-US">Diversity Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：一个扩展点接纳多个扩展。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">良好防御法则（</span>
				<span lang="EN-US">Good Fences Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：如果要交出程序的控制权，首先保护好你自己。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用户决定法则（</span>
				<span lang="EN-US">User Arbitration Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：如果有多个选择，由用户决定使用哪一个。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">明确</span>
				<span lang="EN-US">API</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">法则（</span>
				<span lang="EN-US">Explicit API Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：将</span>
				<span lang="EN-US">API</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与插件内部使用的类分开。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">稳定性法则（</span>
				<span lang="EN-US">Stability Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：如果你已经开始邀请其它人作出贡献，就不要再改变游戏规则。</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<span style="mso-tab-count: 1">       </span>
				</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">保守</span>
				<span lang="EN-US">API</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">法则（</span>
				<span lang="EN-US">Defensive API Rule</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）：只暴露你有信心的</span>
				<span lang="EN-US">API</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，但同时也应该做好准备暴露更多的</span>
				<span lang="EN-US">API</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，因为使用者会要求你这样做。（不含</span>
				<span lang="EN-US">internal</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的包被认为是公开的、允许后续的扩展者使用的；不含</span>
				<span lang="EN-US">internal</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的包，则不是打算拿到插件外使用的。）</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<b style="mso-bidi-font-weight: normal">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">发布者(</span>
						<span lang="EN-US">Publisher</span>)</b>
				<b style="mso-bidi-font-weight: normal">
				</b>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">――发布插件</span>
				<b style="mso-bidi-font-weight: normal">
						<span lang="EN-US">
								<o:p>
								</o:p>
						</span>
				</b>
		</p>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">
				<span style="mso-tab-count: 1">       </span>
		</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">许可法则（</span>
		<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">License Rule</span>
		<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">）：每项贡献品都应该提供许可证。<br /><br /><span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><strong>2、Eclipse </strong></span><span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'"><strong>插件(Plug-in)</strong></span><br /><br /><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">何时需要一个插件类</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-tab-count: 1"><font face="Times New Roman">       </font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">每个插件都由一个插件类来代表。插件类是一个</span><span lang="EN-US"><font face="Times New Roman">Singleton</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，其中提供了一些钩子方法，可以对插件的什么周期事件作出响应。可以在插件第一次加载时读入所需的资源，也可以在插件停止时做必要的清理工资。另外，插件还负责提高一些共享信息。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">投影（</span><span lang="EN-US"><font face="Times New Roman">Shadow</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）的世界</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font face="Times New Roman"><span style="mso-tab-count: 1">       </span>Eclipse</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平台启动时会将所有插件清单文件读入一个插件注册表中，为每个插件创建一个投影。此时不会加载插件本身，只加载它们的描述信息。（</span><span lang="EN-US"><font face="Times New Roman">Platform.getPluginRegistry()</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开发插件时，不要在项目属性中修改构建</span><span lang="EN-US"><font face="Times New Roman">classpath</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，始终在清单文件中修改。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span><span lang="EN-US"><font face="Times New Roman">Eclipse</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中，每个插件都有自己的类加载器（</span><span lang="EN-US"><font face="Times New Roman">class loader</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）和自己的类查找路径（</span><span lang="EN-US"><font face="Times New Roman">classpath</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">），后者将继承该插件所导入的其它插件的</span><span lang="EN-US"><font face="Times New Roman">classpath</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。当插件的类加载器加载插件的第一个类时，就会激活该插件。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">插件类加载器</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">1、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">插件类加载器的上级加载器，</span><span lang="EN-US"><font face="Times New Roman">Eclipse</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的引导加载器，</span><span lang="EN-US"><font face="Times New Roman">boot.jar</font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">2、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">插件本身的类加载器，</span><span lang="EN-US"><font face="Times New Roman">plugin.xml</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">清单文件中的</span><span lang="EN-US"><font face="Times New Roman">&lt;run-time&gt;</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">元素中描述的类。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">3、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">相依插件的类加载器，如果插件依赖于其它插件，在类查找时，会在内部使用一个</span><span lang="EN-US"><font face="Times New Roman">URL</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类加载器。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l1 level1 lfo1; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">4、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不包括应用程序类</span><span lang="EN-US"><font face="Times New Roman">/</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">系统</span><span lang="EN-US"><font face="Times New Roman">CLASSPATH</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">变量的加载器。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">加载扩展的全过程</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">1、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">从</span><span lang="EN-US"><font face="Times New Roman">Eclipse</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平台取得扩展点。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">2、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">取得以在此扩展点上注册的扩展（实现</span><span lang="EN-US"><font face="Times New Roman">IExtension</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口）。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">3、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于每个扩展，取出其中以</span><span lang="EN-US"><font face="Times New Roman">XML</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方式声明的配置元素（实现</span><span lang="EN-US"><font face="Times New Roman">IConfigurationElement</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口）。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">4、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于每个配置元素，根据该元素</span><span lang="EN-US"><font face="Times New Roman">XML</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">声明中</span><span lang="EN-US"><font face="Times New Roman">class</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">属性的值创建一个对象，确保定义的属性完整、有效。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo2; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">5、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将新创建的扩展对象保存到一个集合中，而不是直接返回一个扩展对象。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">理想的开发策略：</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo4; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">1、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">信心：在增加新性能或修改旧结构时，不比担心对原代码造成破坏。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo4; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">2、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">学习：快速而自信地学习</span><span lang="EN-US"><font face="Times New Roman">Eclipse</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">地新领域。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo4; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">3、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设计：鼓励自己和同事认真考虑设计，尤其是代码地外在接口，然后去考虑如何实现。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">测试驱动开发（</span><span lang="EN-US"><font face="Times New Roman">Test-Driven Development, TDD</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）的开发循环：</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l4 level1 lfo3; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">1、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编写欲添加功能的测试。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l4 level1 lfo3; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">2、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">针对这个测试引用到、暂未存在的类和方法，创建一段空的占用程序，使测试通过编译。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l4 level1 lfo3; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">3、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现测试，测试测试应该失败。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l4 level1 lfo3; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman">4、<span style="FONT: 7pt 'Times New Roman'">  </span></font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">尽量对实现代码加以清扫，例如去除其中的重复代码。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">插件的测试策略</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-tab-count: 1"><font face="Times New Roman">       </font></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">从审美的角度，每个插件应该尽可能少的依赖其它插件；从实用的角度，以测试驱动的方式开发插件的每个部分。应该首先创建测试插件，让它依赖于新插件，以便完全用测试来驱动新插件的开发。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">工作副本（</span><span lang="EN-US"><font face="Times New Roman">working copy</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）是</span><span lang="EN-US"><font face="Times New Roman">Eclipse JDT</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引入的一个概念，是原有的编译单元在内存中的复制品。让用户修改时，操作的实际是</span><span lang="EN-US"><font face="Times New Roman">Java</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编辑器所创建的工作副本；当用户保存编译单元时，</span><span lang="EN-US"><font face="Times New Roman">Java</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编辑器才把副本提交到文件系统，此时对编译单元的修改才会以</span><span lang="EN-US"><font face="Times New Roman">Java</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">元素变化增量的形式广播出去。（</span><span lang="EN-US"><font face="Times New Roman">JavaUI.getWorkingCopyManager()</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">视角，定义了（一组）视图和编辑器的排列方式，工作台页面的布局，解决某个完整问题的环境。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">降低插件的维护成本：良好的异常处理和错误报告机制；提供联机帮助文档（</span><span lang="EN-US"><font face="Times New Roman">Eclipse</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span><span lang="EN-US"><font face="Times New Roman">help</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">扩展点的扩展）。</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><o:p><font face="Times New Roman"> </font></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分段（</span><span lang="EN-US"><font face="Times New Roman">fragment</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）使开发者能够向现有的插件中添加代码和资源。（</span><span lang="EN-US"><font face="Times New Roman">fragment.xml</font></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分段的用途：</span></p><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore"><font face="Times New Roman"><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'"><span style="mso-list: Ignore">1、<span style="FONT: 7pt 'Times New Roman'">  </span></span></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为插件提供额外的字符串翻译