﻿<?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-Believe it,do it! -随笔分类-JAVA资料</title><link>http://www.blogjava.net/tunaic/category/34882.html</link><description>Ideal is the beacon. Without ideal, there is no secure direction; without direction ,there is no life. &lt;br&gt;
理想是指路明灯。没有理想，就没有坚定的方向；没有方向，就没有生活。&lt;br&gt;
CTRL+T eclipse</description><language>zh-cn</language><lastBuildDate>Fri, 02 Dec 2011 00:57:29 GMT</lastBuildDate><pubDate>Fri, 02 Dec 2011 00:57:29 GMT</pubDate><ttl>60</ttl><item><title>部署程序svn及eclipse</title><link>http://www.blogjava.net/tunaic/archive/2010/01/21/310397.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Thu, 21 Jan 2010 07:26:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2010/01/21/310397.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/310397.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2010/01/21/310397.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/310397.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/310397.html</trackback:ping><description><![CDATA[<p>一、去掉SVN文件夹<br />
1、建立一个文本文件，取名为kill-svn-folders.reg，内容如下：</p>
<p>Windows Registry Editor Version 5.00</p>
<p>[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN] <br />
@="Delete .SVN Folders"</p>
<p>[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command] <br />
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 &amp;&amp; COLOR 9A &amp;&amp; FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""</p>
<p>保存之后，双击这个reg文件。成功后，在每一个文件夹上点击右键都会有一个&#8220;Delete .SVN Folders&#8221;的选项，点击之后，既可以删除这个文件下下面所有的.svn文件了.<br />
</p>
<p>2. 使用svn自带的export功能。export导出的是一份不带.svn的纯净的代码。<br />
<br />
二、svn导出不同版本文件<br />
TortoiseSVN&nbsp;&nbsp;&#8594;&nbsp; Repo-browser &#8594;&nbsp; 根目录上右键Show log &#8594;&nbsp; 按Ctrl间选两个日志版本对比右键Compare revisions &#8594;&nbsp; 选要导出的文件右键 Export selection to...<br />
<br />
三、eclipse导出war包<br />
eclipse打包是需要TOMCAT插件支持的. <br />
1.在项目上点右键-&gt;properties， <br />
2 在'Tomcat'下'export to war settings选项卡,' <br />
3.输入要导出的war文件路径和文件名，确定,返回项目 <br />
4.在项目上点右键-&gt;tomcat project-&gt;Export to the war file sets in project properties生成WAR包 </p>
<img src ="http://www.blogjava.net/tunaic/aggbug/310397.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2010-01-21 15:26 <a href="http://www.blogjava.net/tunaic/archive/2010/01/21/310397.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>最新版整合Apache2.2.9和Tomcat6.0.18</title><link>http://www.blogjava.net/tunaic/archive/2009/10/22/299296.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Thu, 22 Oct 2009 02:11:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/10/22/299296.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/299296.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/10/22/299296.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/299296.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/299296.html</trackback:ping><description><![CDATA[<p style="text-indent: 2em">APACHE 2.2.9+TOMCAT6.0.18配置负载均衡 </p>
<p style="text-indent: 2em">目标: </p>
<p style="text-indent: 2em">使用 apache 和 tomcat 配置一个可以应用的 web 网站，要达到以下要求： </p>
<p style="text-indent: 2em">1、&nbsp; Apache 做为 HttpServer ，后面连接多个 tomcat 应用实例，并进行负载均衡。 </p>
<p style="text-indent: 2em">2、&nbsp; 为系统设定 Session 超时时间，包括 Apache 和 tomcat </p>
<p style="text-indent: 2em">3、&nbsp; 为系统屏蔽文件列表，包括 Apache 和 tomcat </p>
<p style="text-indent: 2em">注：本例程以一台机器为例子，即同一台机器上装一个apache和4个Tomcat。 </p>
<p style="text-indent: 2em">一、前期准备工作：安装用的程序（前提保证已安装了JDK1.5以上的版本） </p>
<p style="text-indent: 2em">APAHCE 2.2.9下载：apache_2.2.9-win32-x86-no_ssl.msi </p>
<p style="text-indent: 2em">TOMCAT6.0.18下载：apache-tomcat-6.0.18.zip直接解压。 </p>
<p style="text-indent: 2em">二、安装过程 </p>
<p style="text-indent: 2em">APAHCE安装目录：D:\Apache。 </p>
<p style="text-indent: 2em">四个TOMCAT目录：自行解压到(D:\Tomcat集群服务器\)下。分别为 tomcat6.0，tomcat6.01，tomcat6.02，tomcat6.03 </p>
<p style="text-indent: 2em">这几个安装过程就不详细说明了。 </p>
<p style="text-indent: 2em">三、配置 </p>
<p style="text-indent: 2em">1、Apache配置 </p>
<p style="text-indent: 2em">1.1、httpd.conf配置 </p>
<p style="text-indent: 2em">修改APACHE的配置文件D:\Apache \conf\httpd.conf </p>
<p style="text-indent: 2em">将以下Module的注释去掉，这里并没有使用mod_jk.so进行apache和tomcat的链接，从2.X以后apache自身已集成了mod_jk.so的功能。只需简单的把下面几行去掉注释，就相当于以前用mod_jk.so比较繁琐的配置了。这里主要采用了代理的方法，就这么简单。 </p>
<p style="text-indent: 2em">LoadModule proxy_module modules/mod_proxy.so </p>
<p style="text-indent: 2em">LoadModule proxy_connect_module modules/mod_proxy_connect.so </p>
<p style="text-indent: 2em">LoadModule proxy_ftp_module modules/mod_proxy_ftp.so </p>
<p style="text-indent: 2em">LoadModule proxy_http_module modules/mod_proxy_http.so </p>
<p style="text-indent: 2em">LoadModule proxy_ajp_module modules/mod_proxy_ajp.so </p>
<p style="text-indent: 2em">LoadModule proxy_balancer_module modules/mod_proxy_balancer.so </p>
<p style="text-indent: 2em">再找到&lt;IfModule dir_module&gt;&lt;/IfModule&gt;加上index.jsp修改成 </p>
<p style="text-indent: 2em">&lt;IfModule dir_module&gt; </p>
<p style="text-indent: 2em">DirectoryIndex index.html index.jsp </p>
<p style="text-indent: 2em">&lt;/IfModule&gt; </p>
<p style="text-indent: 2em">1.1.1、&nbsp; 在最下面加入 </p>
<p style="text-indent: 2em">ProxyRequests Off </p>
<p style="text-indent: 2em">&lt;proxy balancer://cluster&gt; </p>
<p style="text-indent: 2em">BalancerMember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1 </p>
<p style="text-indent: 2em">BalancerMember ajp:// 127.0.0.1:9009 loadfactor=1 route=jvm2 </p>
<p style="text-indent: 2em">BalancerMember ajp:// 127.0.0.1:9001 loadfactor=1 route=jvm3 </p>
<p style="text-indent: 2em">BalancerMember ajp:// 127.0.0.1:9003 loadfactor=1 route=jvm4 </p>
<p style="text-indent: 2em">&lt;/proxy&gt; </p>
<p style="text-indent: 2em">上面的四个BalancerMember成员是我们配置的tomcat集群。后面会说明的。 </p>
<p style="text-indent: 2em">1.2、httpd-vhosts.conf设置 </p>
<p style="text-indent: 2em">接下来进行虚拟主机的设置。APACHE的虚拟主机设置如下： </p>
<p style="text-indent: 2em">首先要修改 conf/httpd.conf找到(#Include conf/extra/httpd-vhosts.conf) </p>
<p style="text-indent: 2em">把注释去掉。 </p>
<p style="text-indent: 2em"># Virtual hosts </p>
<p style="text-indent: 2em">Include conf/extra/httpd-vhosts.conf </p>
<p style="text-indent: 2em">在文件（extra/httpd-vhosts.conf）最下面加入 </p>
<p style="text-indent: 2em">&lt;VirtualHost *:80&gt; </p>
<p style="text-indent: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerAdmin <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#111;&#115;&#105;&#64;&#49;&#50;&#54;&#46;&#99;&#111;&#109;">rosi@126.com</a> </p>
<p style="text-indent: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerName localhost </p>
<p style="text-indent: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerAlias localhost </p>
<p style="text-indent: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=On </p>
<p style="text-indent: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProxyPassReverse / balancer://cluster/ </p>
<p style="text-indent: 2em">&lt;/VirtualHost&gt; </p>
<p style="text-indent: 2em">其中的域名和路径根据你自己情况设置 </p>
<p style="text-indent: 2em">然后再设置TOMCAT虚拟主机 </p>
<p style="text-indent: 2em">2 配置 tomcat </p>
<p style="text-indent: 2em">2.1.&nbsp; 配置 server 的关闭 </p>
<p style="text-indent: 2em">我们需要在一台机器上跑 4 个不同的 tomcat ，需要修改不同的 tomcat 的关闭口，避免出现端口被占用的情况。其中tomcat6.0用默认值，不修改。其他三个修改。在tomcat6.01\conf, tomcat6.02\conf下和tomcat6.03\conf下的 server.xml 中找到 server, 将： </p>
<p style="text-indent: 2em">&lt;Server port="8005" shutdown="SHUTDOWN"&gt; </p>
<p style="text-indent: 2em">改为 </p>
<p style="text-indent: 2em">&lt;Server port="XXXX" shutdown="SHUTDOWN"&gt; </p>
<p style="text-indent: 2em">XXXX 在这里表示不同的端口：我的其它三个 tomcat 分别使用 9005，8006 ， 9007&nbsp;&nbsp; </p>
<p style="text-indent: 2em">2.2. 配置 Engine </p>
<p style="text-indent: 2em">把原来的配置注释掉，把下面一句去掉注释。并标明jvmRoute="jvm2". </p>
<p style="text-indent: 2em">&lt;Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm2"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p style="text-indent: 2em">以下是原来的配置。 </p>
<p style="text-indent: 2em">&lt;!-- &lt;Engine name="Catalina" defaultHost="localhost"&gt;&nbsp; --&gt; </p>
<p style="text-indent: 2em">其他（tomcat6.02和tomcat6.03）也要同样 配置。注意：jvmRoute配置不要一样。 </p>
<p style="text-indent: 2em">&lt;Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm3"&gt;&nbsp; </p>
<p style="text-indent: 2em">&lt;Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm4"&gt;&nbsp; </p>
<p style="text-indent: 2em">2.3. 配置 Connector </p>
<p style="text-indent: 2em">原来的默认配置。 </p>
<p style="text-indent: 2em">&lt;!-- Define an AJP 1.3 Connector on port 8009 --&gt; </p>
<p style="text-indent: 2em">&lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /&gt; </p>
<p style="text-indent: 2em">这里是apache和tomcat链接的关键，前台apache就是通过AJP协议与tomcat进行通信的，以完成负载均衡的作用。也可以用HTTP协议。大家注意它们是如何连接通信的，上面的红色部分（port="8009"）就是连接的接口了。 </p>
<p style="text-indent: 2em">把其他三个tomcat的&lt;Connector port="XXX" /&gt;port分别改成与上面 </p>
<p style="text-indent: 2em">&lt;proxy balancer://cluster&gt; </p>
<p style="text-indent: 2em">&nbsp;&nbsp;&nbsp;&nbsp; #与tomcat6.0对应，route与&lt;Engine jvmRoute="jvm1"&gt;对应。 </p>
<p style="text-indent: 2em">BalancerMember ajp://127.0.0.1:8009 loadfactor=1 route=jvm1 </p>
<p style="text-indent: 2em">#与tomcat6.01对应，route与&lt;Engine jvmRoute="jvm2"&gt;对应。 </p>
<p style="text-indent: 2em">BalancerMember ajp:// 127.0.0.1:9009 loadfactor=1 route=jvm2 </p>
<p style="text-indent: 2em">#与tomcat6.02对应，route与&lt;Engine jvmRoute="jvm3"&gt;对应。 </p>
<p style="text-indent: 2em">BalancerMember ajp:// 127.0.0.1:9001 loadfactor=1 route=jvm3 </p>
<p style="text-indent: 2em">#与tomcat6.03对应，route与&lt;Engine jvmRoute="jvm4"&gt;对应。 </p>
<p style="text-indent: 2em">BalancerMember ajp:// 127.0.0.1:9003 loadfactor=1 route=jvm4 </p>
<p style="text-indent: 2em">&lt;/proxy&gt; </p>
<p style="text-indent: 2em">中的端口对应，tomcat6.01 的ajp端口port:9009. tomcat6.02 的ajp端口port:9001。tomcat6.03 的ajp端口port:9003.一定要与上面的一致。同时也要把redirectPort的值改成唯一的，确保四个tomcat的都不一样。 </p>
<p style="text-indent: 2em">2.5.配置Cluster(每个tomcat中都要修改) </p>
<p style="text-indent: 2em">原来的配置。 </p>
<p style="text-indent: 2em">&lt;Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/&gt; </p>
<p style="text-indent: 2em">修改为以下的代码：&lt;Receiver port=&#8221;XX&#8221;/&gt;port也要保证唯一性。 </p>
<p style="text-indent: 2em">&lt;Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"&nbsp; channelSendOptions="6"&gt; </p>
<p style="text-indent: 2em">&lt;Manager className="org.apache.catalina.ha.session.BackupManager" </p>
<p style="text-indent: 2em">expireSessionsOnShutdown="false" </p>
<p style="text-indent: 2em">notifyListenersOnReplication="true" </p>
<p style="text-indent: 2em">mapSendOptions="6"/&gt; </p>
<p style="text-indent: 2em">&lt;!-- </p>
<p style="text-indent: 2em">&lt;Manager className="org.apache.catalina.ha.session.DeltaManager" </p>
<p style="text-indent: 2em">expireSessionsOnShutdown="false" </p>
<p style="text-indent: 2em">notifyListenersOnReplication="true"/&gt; </p>
<p style="text-indent: 2em">--&gt; </p>
<p style="text-indent: 2em">&lt;Channel className="org.apache.catalina.tribes.group.GroupChannel"&gt; </p>
<p style="text-indent: 2em">&lt;Membership className="org.apache.catalina.tribes.membership.McastService" </p>
<p style="text-indent: 2em">address="228.0.0.4" </p>
<p style="text-indent: 2em">port="45564" </p>
<p style="text-indent: 2em">frequency="500" </p>
<p style="text-indent: 2em">dropTime="3000"/&gt; </p>
<p style="text-indent: 2em">&lt;Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" </p>
<p style="text-indent: 2em">address="auto" </p>
<p style="text-indent: 2em">port="5001" </p>
<p style="text-indent: 2em">selectorTimeout="100" </p>
<p style="text-indent: 2em">maxThreads="6"/&gt; </p>
<p style="text-indent: 2em">&lt;Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter"&gt; </p>
<p style="text-indent: 2em">&lt;Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/&gt; </p>
<p style="text-indent: 2em">&lt;/Sender&gt; </p>
<p style="text-indent: 2em">&lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/&gt; </p>
<p style="text-indent: 2em">&lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/&gt; </p>
<p style="text-indent: 2em">&lt;Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/&gt; </p>
<p style="text-indent: 2em">&lt;/Channel&gt; </p>
<p style="text-indent: 2em">&lt;Valve className="org.apache.catalina.ha.tcp.ReplicationValve" </p>
<p style="text-indent: 2em">filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/&gt; </p>
<p style="text-indent: 2em">&lt;Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" </p>
<p style="text-indent: 2em">tempDir="/tmp/war-temp/" </p>
<p style="text-indent: 2em">deployDir="/tmp/war-deploy/" </p>
<p style="text-indent: 2em">watchDir="/tmp/war-listen/" </p>
<p style="text-indent: 2em">watchEnabled="false"/&gt; </p>
<p style="text-indent: 2em">&lt;ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/&gt; </p>
<p style="text-indent: 2em">&lt;/Cluster&gt; </p>
<p style="text-indent: 2em">这个设置是主要用以tomcat的集群。 </p>
<p style="text-indent: 2em">四、启动服务，测试tomcat自带的例子 </p>
<p style="text-indent: 2em">1、测试apache和tomcat协作。 </p>
<p style="text-indent: 2em">先在每个tomcat中的\webapps\ROOT下的index.jsp下面加上以下的测试代码部分：(X代表不同的tomcat的输出不同的信息)，把index.html删除，以免影响测试效果。在最后面的加上.即&lt;/table&gt;&lt;/body&gt;之间。 </p>
<p style="text-indent: 2em">&lt;% </p>
<p style="text-indent: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("tomcat6.0X&nbsp; deal&nbsp; with&nbsp; request"); </p>
<p style="text-indent: 2em">%&gt; </p>
<p style="text-indent: 2em">然后再通过http:// 127.0.0.1来访问一下，就会出现大家熟悉的猫猫。 </p>
<p style="text-indent: 2em">然后再通过分别访问 </p>
<p style="text-indent: 2em">http:// 127.0.0.1:8080， http:// 127.0.0.1:9080，http:// 127.0.0.1:8081，http:// 127.0.0.1:9002它们访问的内容和上面的http:// 127.0.0.1是一样的。 </p>
<p style="text-indent: 2em">这样就说明apache和TOMCAT整合成功！ </p>
<p style="text-indent: 2em">2、测试均衡器 </p>
<p style="text-indent: 2em">通过http:// 127.0.0.1多次访问，要想看到真正的效果，必须用一些压力测试工具，可用微软Microsoft Web Application Stress Tool进行简单压力测试，不然你靠不停刷新是体现不出来的，你只会在一个tomcat的控制台有输出结果。只用用压力测试工具模拟大量用户同时访问，你会发现四个tomcat控制台均有打出控制信息，说明均衡器工作正常。 </p>
<p style="text-indent: 2em">3、测试Session复制</p>
<p style="text-indent: 2em">访问url： <a href="http://localhost/examples/servlet/SessionExample">http://localhost/examples/servlet/SessionExample</a> 可以得到一个关于session的例子，我们用它来测试集群的错误恢复能力。</p>
<p style="text-indent: 2em">测试步骤如下：</p>
<p style="text-indent: 2em">关闭tomcat1和tomcat2；</p>
<p style="text-indent: 2em">启动tomcat1</p>
<p style="text-indent: 2em">在浏览器中输入属性名tomcat1和属性值tomcat1再提交，返回的页面显示session中有刚刚输入的tomcat1属性；</p>
<p style="text-indent: 2em">启动tomcat2;</p>
<p style="text-indent: 2em">过一会后（等待tomcat2和tomcat1通信并复制信息）关闭tomcat1；</p>
<p style="text-indent: 2em">在浏览器中输入属性名tomcat2和属性值tomcat2再提交，返回的页面显示session中有刚刚输入的tomcat2属性，还有先前输入的tomcat1属性；</p>
<p style="text-indent: 2em">启动tomcat1；</p>
<p style="text-indent: 2em">过一会后（等待tomcat2和tomcat1通信并复制信息）关闭tomcat2；</p>
<p style="text-indent: 2em">在浏览器中输入属性名tomcat11和属性值tomcat11再提交，返回的页面显示session中有刚刚输入的tomcat11属性，还有先前输入的tomcat1和tomcat2属性;</p>
<img src ="http://www.blogjava.net/tunaic/aggbug/299296.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-10-22 10:11 <a href="http://www.blogjava.net/tunaic/archive/2009/10/22/299296.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA面试精选26题</title><link>http://www.blogjava.net/tunaic/archive/2009/10/14/298161.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Wed, 14 Oct 2009 02:44:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/10/14/298161.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/298161.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/10/14/298161.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/298161.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/298161.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;&nbsp;&nbsp;1.&nbsp;float型float&nbsp;f=3.4是否正确?　　答：不正确，应为float&nbsp;f=3.4f　　2.&nbsp;当一个对象被当作参数传递到一个方法后，此方法可改变这个对象的属性，并可返回变化后的结果，那么这里到底是值传递还是引用传递?　　答：是引用传递。　　3.&nbsp;在java中一个类被声明为fi...&nbsp;&nbsp;<a href='http://www.blogjava.net/tunaic/archive/2009/10/14/298161.html'>阅读全文</a><img src ="http://www.blogjava.net/tunaic/aggbug/298161.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-10-14 10:44 <a href="http://www.blogjava.net/tunaic/archive/2009/10/14/298161.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>工程打war包方法</title><link>http://www.blogjava.net/tunaic/archive/2009/08/27/292808.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Thu, 27 Aug 2009 05:58:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/08/27/292808.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/292808.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/08/27/292808.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/292808.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/292808.html</trackback:ping><description><![CDATA[<p>(1)在命令行中运用Jar命令</p>
<p>假定有一个Web应用：C:\myHome</p>
<p>myHome/WEB-INF/&#8230;&#8230;<br />
myHome/image/&#8230;&#8230;<br />
myHome/src/&#8230;&#8230;<br />
myHome/index.jsp</p>
<p>在命令行窗口下执行如下命令：</p>
<p>C:\&gt;cd/d &nbsp;c:\myHome</p>
<p>C:\myHome\&gt;jar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myhome.war&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */&nbsp;&nbsp;&nbsp;&nbsp; .</p>
<p>解释：jar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [A-&gt;war包名].war&nbsp;&nbsp; [B-&gt;资源文件及文件夹]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [C-&gt;将要生成war包的目标文件夹]</p>
<p>&#8220;*/&#8221;（B-&gt;）代表当前目录（C:\myHome）下的所有文件及文件夹。</p>
<p>&#8220;.&#8221;&nbsp;&nbsp;&nbsp; （C-&gt;）表明将要在当前目录中生成war包。</p>
<p>操作完成后，找到C:\myHome下新生成的myhome.war，将其拷入TOMCAT_HOME/webapps/下。然后启动Tomcat即可。</p>
<p>(2)利用IDE工具打包,如Eclipse</p>
<p>右键点击你想打包的文件或者项目，选择&#8220;导出...&#8221;,在弹出的对话框中选择&#8220;WAR文件&#8221; ，上面有许多选项，还可以选&#8220;EAR&#8221;，&#8220;JAR&#8221;.</p>
 <img src ="http://www.blogjava.net/tunaic/aggbug/292808.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-08-27 13:58 <a href="http://www.blogjava.net/tunaic/archive/2009/08/27/292808.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用JAVA调用.net的webservice实例</title><link>http://www.blogjava.net/tunaic/archive/2009/05/18/271318.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Mon, 18 May 2009 05:57:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/05/18/271318.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/271318.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/05/18/271318.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/271318.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/271318.html</trackback:ping><description><![CDATA[&nbsp;首先登录www.wopos.com/webservice/Weather.asmx?op=getWeather。可以看到如下的SOAP信息&nbsp;<br />
<strong><font color="#ff0000">请求:</font></strong><br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td>
            <table class="ubb_code" cellspacing="0" cellpadding="6" width="95%" align="right" border="0">
                <tbody>
                    <tr>
                        <td><strong>以下内容为程序代码:</strong><br />
                        <br />
                        POST&nbsp;/webservice/Weather.asmx&nbsp;http/1.1<br />
                        Host:&nbsp;www.wopos.com<br />
                        Content-Type:&nbsp;text/xml;&nbsp;charset=utf-8<br />
                        Content-Length:&nbsp;length<br />
                        SOAPAction:&nbsp;"http://tempuri.org/getWeather"<br />
                        <br />
                        &lt;?xml&nbsp;version="1.0"&nbsp;encoding="utf-8"?&gt;<br />
                        &lt;soap:Envelope&nbsp;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&nbsp;xmlns:xsd="http://www.w3.org/2001/XMLSchema"&nbsp;xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;<br />
                        &nbsp;&nbsp;&lt;soap:Body&gt;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&lt;getWeather&nbsp;xmlns="http://tempuri.org/"&gt;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mCity&gt;string&lt;/mCity&gt;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&lt;/getWeather&gt;<br />
                        &nbsp;&nbsp;&lt;/soap:Body&gt;<br />
                        &lt;/soap:Envelope&gt;<br />
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
把XML部分全部复制下来创建一个XML文件（普通的文本文件也可以)，为了以后编程方面，把<br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td>
            <table class="ubb_code" cellspacing="0" cellpadding="6" width="95%" align="right" border="0">
                <tbody>
                    <tr>
                        <td><strong>以下内容为程序代码:</strong><br />
                        <br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&lt;mCity&gt;string&lt;/mCity&gt;&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br />
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
改成<br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td>
            <table class="ubb_code" cellspacing="0" cellpadding="6" width="95%" align="right" border="0">
                <tbody>
                    <tr>
                        <td><strong>以下内容为程序代码:</strong><br />
                        <br />
                        &nbsp;&nbsp;&nbsp;&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;&nbsp;&lt;mCity&gt;＄{city}＄&lt;/mCity&gt;&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br />
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
以weathersoap.xml保存在以后生成的类的同一目录。<br />
<br />
<strong><font color="#ff0000">响应:</font></strong><br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td>
            <table class="ubb_code" cellspacing="0" cellpadding="6" width="95%" align="right" border="0">
                <tbody>
                    <tr>
                        <td><strong>以下内容为程序代码:</strong><br />
                        <br />
                        http/1.1&nbsp;200&nbsp;OK<br />
                        Content-Type:&nbsp;text/xml;&nbsp;charset=utf-8<br />
                        Content-Length:&nbsp;length<br />
                        <br />
                        &lt;?xml&nbsp;version="1.0"&nbsp;encoding="utf-8"?&gt;<br />
                        &lt;soap:Envelope&nbsp;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&nbsp;xmlns:xsd="h&nbsp;ttp://www.w3.org/2001/XMLSchema"&nbsp;xmlns:soap="h&nbsp;ttp://schemas.xmlsoap.org/soap/envelope/"&gt;<br />
                        &nbsp;&nbsp;&lt;soap:Body&gt;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&lt;getWeatherResponse&nbsp;xmlns="h&nbsp;ttp://tempuri.org/"&gt;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;getWeatherResult&gt;string&lt;/getWeatherResult&gt;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&lt;/getWeatherResponse&gt;<br />
                        &nbsp;&nbsp;&lt;/soap:Body&gt;<br />
                        &lt;/soap:Envelope&gt;<br />
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
在后面对XML的解释要用到响应部分的XML描述<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;接下就开始写代码了。<br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td>
            <table class="ubb_code" cellspacing="0" cellpadding="6" width="95%" align="right" border="0">
                <tbody>
                    <tr>
                        <td><strong>以下内容为程序代码:</strong><br />
                        <br />
                        package&nbsp;jaqcy.weatherreport.client;<br />
                        <br />
                        import&nbsp;java.io.*;<br />
                        import&nbsp;java.net.*;<br />
                        import&nbsp;javax.xml.parsers.*;<br />
                        import&nbsp;org.w3c.dom.*;<br />
                        /**<br />
                        &nbsp;*<br />
                        &nbsp;*&nbsp;@author&nbsp;jaqcy<br />
                        &nbsp;*/<br />
                        public&nbsp;class&nbsp;WeatherReport&nbsp;<br />
                        {&nbsp;&nbsp;&nbsp;&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;static&nbsp;String&nbsp;getSoapRequest(String&nbsp;city)//city为要查询天气的城市名<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class&nbsp;cls=Object.class;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStreamReader&nbsp;isr=new&nbsp;InputStreamReader(cls.getResourceAsStream("/jaqcy/weatherreport/client/weathersoap.xml"）);//读取存在weathersoap的SOAP信息<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader&nbsp;reader=new&nbsp;BufferedReader(isr);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;soap="";<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;tmp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while((tmp=reader.readLine())!=null)<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soap+=tmp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader.close();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isr.close();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;soap.replace("＄{city}＄",city);//用传入的参数city替换原来的＄{city}＄<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;(Exception&nbsp;ex)&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ex.printStackTrace();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;null;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;/*<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;*返回InputStream是因为w3c&nbsp;DOM中Document的parse方法可<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;*以接受InputStream类型的参数，方面在下一步对XML的解释<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;*/<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;static&nbsp;InputStream&nbsp;getSoapInputStream(String&nbsp;city)throws&nbsp;Exception<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;soap=getSoapRequest(city);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(soap==null)<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;null;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;URL&nbsp;url=new&nbsp;URL("http://www.wopos.com/webservice/Weather.asmx"）;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;URLConnection&nbsp;conn=url.openConnection();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.setUseCaches(false);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.setDoInput(true);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.setDoOutput(true);<br />
                        <br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.setRequestProperty("Content-Length",&nbsp;Integer.toString(soap.length()));<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.setRequestProperty("Content-Type",&nbsp;"text/xml;&nbsp;charset=utf-8"）;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.setRequestProperty("SOAPAction","\"http://tempuri.org/getWeather\""）;<br />
                        <br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OutputStream&nbsp;os=conn.getOutputStream();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OutputStreamWriter&nbsp;osw=new&nbsp;OutputStreamWriter(os,"utf-8"）;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;osw.write(soap);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;osw.flush();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;osw.close();<br />
                        <br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStream&nbsp;is=conn.getInputStream();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;is;&nbsp;&nbsp;&nbsp;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch(Exception&nbsp;e)<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;null;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        /*<br />
                        &nbsp;&nbsp;*用W3C&nbsp;DOM对返回的XML进行解释<br />
                        &nbsp;&nbsp;*<br />
                        &nbsp;&nbsp;*/<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;String&nbsp;getWeather(String&nbsp;city)<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Document&nbsp;doc;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DocumentBuilderFactory&nbsp;dbf=DocumentBuilderFactory.newInstance();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dbf.setNamespaceAware(true);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DocumentBuilder&nbsp;db=dbf.newDocumentBuilder();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStream&nbsp;is=getSoapInputStream(city);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doc=db.parse(is);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NodeList&nbsp;nl=doc.getElementsByTagName("getWeatherResult"）;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node&nbsp;n=nl.item(0);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;weather=n.getFirstChild().getNodeValue();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is.close();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;weather;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch(Exception&nbsp;e)<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;null;<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        }<br />
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
写个main方法检验一下结果<br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td>
            <table class="ubb_code" cellspacing="0" cellpadding="6" width="95%" align="right" border="0">
                <tbody>
                    <tr>
                        <td><strong>以下内容为程序代码:</strong><br />
                        <br />
                        <br />
                        &nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;void&nbsp;main(String[]&nbsp;args)throws&nbsp;Exception<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;{<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(WeatherReport.getWeather("珠海"）);<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;}<br />
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<br />
结果如下<br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
    <tbody>
        <tr>
            <td>
            <table class="ubb_code" cellspacing="0" cellpadding="6" width="95%" align="right" border="0">
                <tbody>
                    <tr>
                        <td><strong>以下内容为程序代码:</strong><br />
                        <br />
                        城市==珠海,日期==4．02-4．03,图1==http://weather.tq121.com.cn/images/a1.gif,图2==http://weather.tq121.com.cn/images/00.gif,天气==多云,温度==28℃~22℃,风==微风,紫外线==弱<br />
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
 <img src ="http://www.blogjava.net/tunaic/aggbug/271318.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-05-18 13:57 <a href="http://www.blogjava.net/tunaic/archive/2009/05/18/271318.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将图片文件写入数据库BLOB</title><link>http://www.blogjava.net/tunaic/archive/2009/05/18/271317.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Mon, 18 May 2009 05:51:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/05/18/271317.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/271317.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/05/18/271317.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/271317.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/271317.html</trackback:ping><description><![CDATA[&nbsp; import &nbsp; java.sql.*; &nbsp; <br />
&nbsp; import &nbsp; oracle.sql.*; &nbsp; <br />
&nbsp; import &nbsp; java.io.*; &nbsp; <br />
&nbsp; import &nbsp; oracle.jdbc.driver.OracleResultSet; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; public &nbsp; class &nbsp; WriteBlob &nbsp; { &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; public &nbsp; static &nbsp; void &nbsp; main(String[] &nbsp; args) &nbsp; { &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; try &nbsp; { &nbsp; <br />
&nbsp; // &nbsp; 连接数据库 &nbsp; <br />
&nbsp; //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); &nbsp; <br />
&nbsp; //Connection &nbsp; conn &nbsp; = &nbsp; DriverManager.getConnection("jdbc:odbc:Yzl","pda","pwpda"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; Class.forName("oracle.jdbc.driver.OracleDriver"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; Connection &nbsp; conn &nbsp; = &nbsp; DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:SISSI","pda","pwpda"); &nbsp; <br />
&nbsp; conn.setAutoCommit(false); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; // &nbsp; 获取源照片数据 &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; BLOB &nbsp; &nbsp; blob &nbsp; = &nbsp; null; &nbsp; <br />
&nbsp; Blob &nbsp; &nbsp; blob2 &nbsp; = &nbsp; null; &nbsp; <br />
&nbsp; String &nbsp; fileName &nbsp; = &nbsp; "c:\\01.jpg"; &nbsp; <br />
&nbsp; File &nbsp; f &nbsp; = &nbsp; new &nbsp; File(fileName); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; // &nbsp; 先插入一条记录,用于后面获得一个Blob对象 &nbsp; <br />
&nbsp; PreparedStatement &nbsp; pstmt &nbsp; = &nbsp; conn.prepareStatement("insert &nbsp; into &nbsp; javatest(PICNAME,content) &nbsp; values(?,empty_blob())"); &nbsp; <br />
&nbsp; pstmt.setString(1,"Yzl"); &nbsp; &nbsp; <br />
&nbsp; pstmt.executeUpdate(); &nbsp; <br />
&nbsp; pstmt.close(); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; // &nbsp; 获得Blob对象(由于Blob是接口,不能实例化,所以只好用这种曲折方法获得) &nbsp; <br />
&nbsp; pstmt &nbsp; = &nbsp; conn.prepareStatement("SELECT &nbsp; content &nbsp; FROM &nbsp; JAVATEST &nbsp; WHERE &nbsp; trim(PICNAME)=? &nbsp; "); &nbsp; <br />
&nbsp; pstmt.setString(1,"Yzl"); &nbsp; <br />
&nbsp; ResultSet &nbsp; rset &nbsp; = &nbsp; pstmt.executeQuery(); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; if &nbsp; (rset.next()) &nbsp; blob &nbsp; = &nbsp; (BLOB)rset.getBlob(1); &nbsp; <br />
&nbsp; pstmt.close(); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; if &nbsp; (blob &nbsp; == &nbsp; null){ &nbsp; <br />
&nbsp; System.out.println("blob &nbsp; is &nbsp; null"); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; conn.close(); &nbsp; <br />
&nbsp; return &nbsp; ; &nbsp; <br />
&nbsp; } &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; // &nbsp; 填充Blob值,用于提交到数据库 &nbsp; <br />
&nbsp; FileInputStream &nbsp; fin &nbsp; = &nbsp; new &nbsp; FileInputStream(f); &nbsp; <br />
&nbsp; System.out.println("file &nbsp; size &nbsp; = &nbsp; " &nbsp; + &nbsp; fin.available()); &nbsp; <br />
&nbsp; OutputStream &nbsp; out &nbsp; = &nbsp; blob.getBinaryOutputStream(); &nbsp; <br />
&nbsp; byte[] &nbsp; data &nbsp; = &nbsp; new &nbsp; byte[(int)fin.available()]; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 获取 &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.read(data); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.write(data); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 关闭资源 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.close(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.close(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 插入数据库 &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pstmt &nbsp; = &nbsp; conn.prepareStatement("update &nbsp; javatest &nbsp; set &nbsp; content=? &nbsp; where &nbsp; PICNAME=?"); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pstmt.setBlob(1,blob); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pstmt.setString(2,"Yzl"); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pstmt.executeUpdate(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pstmt.close(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 提交 &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.commit(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 获取数据库中的照片 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; pstmt &nbsp; = &nbsp; conn.prepareStatement("SELECT &nbsp; content &nbsp; FROM &nbsp; JAVATEST &nbsp; WHERE &nbsp; trim(PICNAME)=? &nbsp; "); &nbsp; <br />
&nbsp; pstmt.setString(1,"Yzl"); &nbsp; <br />
&nbsp; rset &nbsp; = &nbsp; pstmt.executeQuery(); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; if &nbsp; (rset.next()) &nbsp; blob &nbsp; = &nbsp; (BLOB)((OracleResultSet)rset).getBLOB(1); &nbsp; <br />
&nbsp; pstmt.close(); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; if &nbsp; (blob &nbsp; == &nbsp; null){ &nbsp; <br />
&nbsp; System.out.println("blob2 &nbsp; is &nbsp; null"); &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; conn.close(); &nbsp; <br />
&nbsp; return &nbsp; ; &nbsp; <br />
&nbsp; } &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; // &nbsp; 输出到磁盘 &nbsp; <br />
&nbsp; // &nbsp; 获得 &nbsp; <br />
&nbsp; FileOutputStream &nbsp; fout &nbsp; = &nbsp; new &nbsp; FileOutputStream(new &nbsp; File("c:\\02.jpg")); &nbsp; <br />
&nbsp; InputStream &nbsp; in &nbsp; = &nbsp; blob.asciiStreamValue(); &nbsp; <br />
&nbsp; data &nbsp; = &nbsp; new &nbsp; byte[(int)in.available()]; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; System.out.println("数据库中照片的字节数:"+in.available()); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 此句总是为 &nbsp; 0 &nbsp; 不知道为什么,有谁知道吗? &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 输出 &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in.read(data); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fout.write(data); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 关闭资源 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.close(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.close(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 打开 &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Process &nbsp; pro &nbsp; = &nbsp; Runtime.getRuntime().exec("cmd &nbsp; /c &nbsp; start &nbsp; c:\\02.jpg"); &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; catch &nbsp; (SQLException &nbsp; e) &nbsp; { &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.err.println(e.getMessage()); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; catch &nbsp; (IOException &nbsp; e) &nbsp; { &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.err.println(e.getMessage()); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; catch(ClassNotFoundException &nbsp; e){ &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace(); &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; }
 <img src ="http://www.blogjava.net/tunaic/aggbug/271317.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-05-18 13:51 <a href="http://www.blogjava.net/tunaic/archive/2009/05/18/271317.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数据库xml互相操作！！！</title><link>http://www.blogjava.net/tunaic/archive/2009/05/18/271316.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Mon, 18 May 2009 05:47:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/05/18/271316.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/271316.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/05/18/271316.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/271316.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/271316.html</trackback:ping><description><![CDATA[<span style="color: #800000"><strong>JAVA如何将XML文档里的数据写入oracle数据库</strong></span>
<div id="user_content_mass">
<p>
<p>import org.w3c.dom.Document;<br />
import org.w3c.dom.Element;<br />
import org.w3c.dom.NodeList;<br />
import javax.xml.parsers.DocumentBuilderFactory;<br />
import javax.xml.parsers.DocumentBuilder;<br />
import javax.xml.parsers.ParserConfigurationException;<br />
import org.xml.sax.SAXException;<br />
import java.sql.Connection;<br />
import java.sql.DriverManager;<br />
import java.sql.Statement;<br />
import java.sql.SQLException;<br />
import java.io.IOException;</p>
<p>public class test1<br />
{<br />
&nbsp;static Connection conn=null;<br />
&nbsp;static String deptno,dname,loc,sql;<br />
&nbsp;static String url="jdbc:oracle:oci8:@hydb";<br />
&nbsp;public static void main(String[] args)<br />
&nbsp;{<br />
&nbsp;&nbsp;try<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Class.forName("oracle.jdbc.driver.OracleDriver");<br />
&nbsp;&nbsp;&nbsp;conn=DriverManager.getConnection(url,"scott","tiger");<br />
&nbsp;&nbsp;&nbsp;Statement st=conn.createStatement();<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();<br />
&nbsp;&nbsp;&nbsp;DocumentBuilder builder=factory.newDocumentBuilder();<br />
&nbsp;&nbsp;&nbsp;Document doc=builder.parse("dept.xml");<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;NodeList node=doc.getElementsByTagName("PERSON");<br />
&nbsp;&nbsp;&nbsp;System.out.println(node.getLength());<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;for(int i=0;i&lt;node.getLength();i++)<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element element=(Element)node.item(i);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;deptno=element.getElementsByTagName("DEPTNO").item(0).getFirstChild().getNodeValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;dname=element.getElementsByTagName("DNAME").item(0).getFirstChild().getNodeValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;loc=element.getElementsByTagName("LOC").item(0).getFirstChild().getNodeValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;sql="insert into person values('"+deptno+"','"+dname+"','"+loc+"')";<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;st.executeUpdate(sql);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;st.close();<br />
&nbsp;&nbsp;&nbsp;conn.close();<br />
&nbsp;&nbsp;&nbsp;System.out.println("插入成功！！！");<br />
&nbsp;&nbsp;}catch(ClassNotFoundException e)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
&nbsp;&nbsp;}catch(SQLException e1)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e1.printStackTrace();<br />
&nbsp;&nbsp;}catch(ParserConfigurationException e2)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e2.printStackTrace();<br />
&nbsp;&nbsp;}catch(SAXException e3)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e3.printStackTrace();<br />
&nbsp;&nbsp;}catch(IOException e4)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e4.printStackTrace();<br />
&nbsp;&nbsp;}<br />
&nbsp;}<br />
}</p>
<p>&nbsp;</p>
<p>dept.xml文件</p>
<p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p>
<p>&lt;COMP&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;10&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;ACCOUNTING&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;NEW YORK&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;20&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;RESEARCH&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;DALLAS&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;30&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;SALES&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;CHICAGO&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;40&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;OPERATIONS&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;BOSTON&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&lt;/COMP&gt;</p>
<p>&nbsp;</p>
</div>
<p><span style="color: #800000"><strong>JAVA如何将oracle数据库里的数据写入XML文档</strong></span><br />
<br />
import org.w3c.dom.Document;<br />
import org.w3c.dom.Element;<br />
import org.apache.crimson.tree.XmlDocument;<br />
import javax.xml.parsers.DocumentBuilderFactory;<br />
import javax.xml.parsers.DocumentBuilder;<br />
import javax.xml.parsers.ParserConfigurationException;<br />
import java.sql.Connection;<br />
import java.sql.DriverManager;<br />
import java.sql.Statement;<br />
import java.sql.ResultSet;<br />
import java.sql.SQLException;<br />
import java.io.File;<br />
import java.io.FileOutputStream;<br />
import java.io.IOException;<br />
import java.io.FileNotFoundException;<br />
import java.io.IOException;<br />
import org.xml.sax.SAXException;</p>
<p>public class test<br />
{<br />
&nbsp;static Connection conn=null;<br />
&nbsp;static String sql;<br />
&nbsp;static String url="jdbc:oracle:oci8:@hydb";<br />
&nbsp;public static void main(String[] args)<br />
&nbsp;{<br />
&nbsp;&nbsp;try<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Class.forName("oracle.jdbc.driver.OracleDriver");<br />
&nbsp;&nbsp;&nbsp;conn=DriverManager.getConnection(url,"scott","tiger");<br />
&nbsp;&nbsp;&nbsp;Statement st=conn.createStatement();<br />
&nbsp;&nbsp;&nbsp;ResultSet rs=st.executeQuery("select * from dept");<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();<br />
&nbsp;&nbsp;&nbsp;DocumentBuilder builder=factory.newDocumentBuilder();<br />
&nbsp;&nbsp;&nbsp;Document doc=builder.newDocument();<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;Element comp=doc.createElement("COMP");<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;while(rs.next())<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element person=doc.createElement("PERSON");<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element deptno=doc.createElement("DEPTNO");<br />
&nbsp;&nbsp;&nbsp;&nbsp;deptno.appendChild(doc.createTextNode(String.valueOf(rs.getInt(1))));<br />
&nbsp;&nbsp;&nbsp;&nbsp;person.appendChild(deptno);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element dname=doc.createElement("DNAME");<br />
&nbsp;&nbsp;&nbsp;&nbsp;dname.appendChild(doc.createTextNode(rs.getString(2)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;person.appendChild(dname);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element loc=doc.createElement("LOC");<br />
&nbsp;&nbsp;&nbsp;&nbsp;loc.appendChild(doc.createTextNode(rs.getString(3)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;person.appendChild(loc);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;comp.appendChild(person);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;rs.close();<br />
&nbsp;&nbsp;&nbsp;st.close();<br />
&nbsp;&nbsp;&nbsp;conn.close();<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;doc.appendChild(comp);<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;((XmlDocument)doc).write(new FileOutputStream(new File("dept.xml")));<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;System.out.println("操作成功！！！");<br />
&nbsp;&nbsp;}catch(ClassNotFoundException e)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
&nbsp;&nbsp;}catch(SQLException e1)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e1.printStackTrace();<br />
&nbsp;&nbsp;}catch(ParserConfigurationException e2)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e2.printStackTrace();<br />
&nbsp;&nbsp;}catch(FileNotFoundException e3)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e3.printStackTrace();<br />
&nbsp;&nbsp;}catch(IOException e4)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e4.printStackTrace();<br />
&nbsp;&nbsp;}<br />
&nbsp;}<br />
}</p>
<p>dept.xml文件</p>
<p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p>
<p>&lt;COMP&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;10&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;ACCOUNTING&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;NEW YORK&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;20&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;RESEARCH&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;DALLAS&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;30&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;SALES&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;CHICAGO&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&nbsp; &lt;PERSON&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DEPTNO&gt;40&lt;/DEPTNO&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;DNAME&gt;OPERATIONS&lt;/DNAME&gt;<br />
&nbsp;&nbsp;&nbsp; &lt;LOC&gt;BOSTON&lt;/LOC&gt;<br />
&nbsp; &lt;/PERSON&gt;<br />
&lt;/COMP&gt;<br />
<span style="color: #800000"><strong>JAVA如何将SQLSERVER数据库里的数据写入XML文档</strong></span><br />
</p>
<div id="user_content_mass">
<p>
<p>import org.w3c.dom.Document;<br />
import org.w3c.dom.Element;<br />
import org.apache.crimson.tree.XmlDocument;<br />
import javax.xml.parsers.DocumentBuilderFactory;<br />
import javax.xml.parsers.DocumentBuilder;<br />
import javax.xml.parsers.ParserConfigurationException;<br />
import java.sql.Connection;<br />
import java.sql.DriverManager;<br />
import java.sql.Statement;<br />
import java.sql.ResultSet;<br />
import java.sql.SQLException;<br />
import java.io.File;<br />
import java.io.FileOutputStream;<br />
import java.io.IOException;<br />
import java.io.FileNotFoundException;<br />
import java.io.IOException;<br />
import org.xml.sax.SAXException;</p>
<p>public class test2<br />
{<br />
&nbsp;static Connection conn=null;<br />
&nbsp;static String sql;<br />
&nbsp;static String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=pubs";<br />
&nbsp;public static void main(String[] args)<br />
&nbsp;{<br />
&nbsp;&nbsp;try<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");<br />
&nbsp;&nbsp;&nbsp;conn=DriverManager.getConnection(url,"sa","");<br />
&nbsp;&nbsp;&nbsp;Statement st=conn.createStatement();<br />
&nbsp;&nbsp;&nbsp;ResultSet rs=st.executeQuery("select * from jobs");<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();<br />
&nbsp;&nbsp;&nbsp;DocumentBuilder builder=factory.newDocumentBuilder();<br />
&nbsp;&nbsp;&nbsp;Document doc=builder.newDocument();<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;Element comp=doc.createElement("COMP");<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;while(rs.next())<br />
&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element person=doc.createElement("PERSON");<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element job_id=doc.createElement("JOB_ID");<br />
&nbsp;&nbsp;&nbsp;&nbsp;job_id.appendChild(doc.createTextNode(String.valueOf(rs.getInt(1))));<br />
&nbsp;&nbsp;&nbsp;&nbsp;person.appendChild(job_id);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element job_desc=doc.createElement("JOB_DESC");<br />
&nbsp;&nbsp;&nbsp;&nbsp;job_desc.appendChild(doc.createTextNode(rs.getString(2)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;person.appendChild(job_desc);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element min_lvl=doc.createElement("MIN_LVL");<br />
&nbsp;&nbsp;&nbsp;&nbsp;min_lvl.appendChild(doc.createTextNode(String.valueOf(rs.getInt(3))));<br />
&nbsp;&nbsp;&nbsp;&nbsp;person.appendChild(min_lvl);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;Element max_lvl=doc.createElement("MAX_LVL");<br />
&nbsp;&nbsp;&nbsp;&nbsp;max_lvl.appendChild(doc.createTextNode(String.valueOf(rs.getInt(4))));<br />
&nbsp;&nbsp;&nbsp;&nbsp;person.appendChild(max_lvl);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;comp.appendChild(person);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;rs.close();<br />
&nbsp;&nbsp;&nbsp;st.close();<br />
&nbsp;&nbsp;&nbsp;conn.close();<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;doc.appendChild(comp);<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;((XmlDocument)doc).write(new FileOutputStream(new File("jobs.xml")));<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;System.out.println("操作成功！！！");<br />
&nbsp;&nbsp;}catch(ClassNotFoundException e)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
&nbsp;&nbsp;}catch(SQLException e1)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e1.printStackTrace();<br />
&nbsp;&nbsp;}catch(ParserConfigurationException e2)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e2.printStackTrace();<br />
&nbsp;&nbsp;}catch(FileNotFoundException e3)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e3.printStackTrace();<br />
&nbsp;&nbsp;}catch(IOException e4)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;e4.printStackTrace();<br />
&nbsp;&nbsp;}<br />
&nbsp;}<br />
}</p>
</div>
<span style="color: #800000"><strong>java解析xml字符串<br />
</strong><span style="color: #000000">import java.util.*;<br />
import test.*;<br />
<br />
public class MyDOMBean implements java.io.Serializable {<br />
&nbsp; &nbsp; &nbsp; &nbsp; Vector vec = new Vector();<br />
<br />
&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; public MyDOMBean() {<br />
&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp;&nbsp;public Vector getMappingValueNode(String strIndex,String strArea)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;NodeIterator keys = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Document doc = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;try<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;DocumentBuilderFactory factory =<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DocumentBuilderFactory.newInstance();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;DocumentBuilder builder = factory.newDocumentBuilder();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;doc = builder.parse("/opt/tomcat/jakarta-tomcat-5.0.28/webapps/Visual/WEB-INF/qa.xml");<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;String xpath = "/root/" + strArea + "/*";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;keys = XPathAPI.selectNodeIterator(doc, xpath);<br />
<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Node key = null;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;int i = 0;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; while ((key = keys.nextNode()) != null)<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; NodeIterator aKey = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; NodeIterator pKey = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Node name = key.getFirstChild();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; name = name.getNextSibling();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; QuesAnswer qa = new QuesAnswer();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; String tempQ = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; tempQ = name.getFirstChild().getNodeValue().toString();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; name = name.getNextSibling();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; name = name.getNextSibling();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; String strTempA = "./answer";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; aKey = XPathAPI.selectNodeIterator(key,strTempA);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Node tempKeyA = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ArrayList listA = new ArrayList();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; String tempP = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; while((tempKeyA = aKey.nextNode()) != null){<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listA.add(tempKeyA.getFirstChild().getNodeValue().toString());<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; String[] tempA = new String[listA.size()];<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; for(int l = 0;l&lt;listA.size();l++){<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempA[l] = (String)listA.get(l);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; String strTempP = "./pic";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; pKey = XPathAPI.selectNodeIterator(key,strTempP);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Node tempKeyP = null;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; while((tempKeyP = pKey.nextNode()) !=null){<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempP = tempKeyP.getAttributes().getNamedItem("file").getNodeValue();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &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; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if(strIndex==null||strIndex.equals("")){<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setQuestion(tempQ);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setAnswer(tempA);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setPicture(tempP);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vec.add(qa);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (tempQ.indexOf(strIndex)&gt;= 0){<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setQuestion(tempQ);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setAnswer(tempA);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setPicture(tempP);&nbsp; &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; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vec.add(qa);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int h = 0;h&lt;tempA.length;h++){<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(tempA[h].indexOf(strIndex)&gt;=0){<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setQuestion(tempQ);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setAnswer(tempA);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qa.setPicture(tempP);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vec.add(qa);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}catch(Exception ex)<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;System.out.println("[Error] Can not get mapping Value.");<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;System.out.println(ex);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return vec;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
<br />
}<br />
2、<br />
<div class="t_msgfont" id="message466023">package test;<br />
<br />
public class QuesAnswer{<br />
&nbsp; &nbsp; &nbsp; &nbsp; private String question = null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private String[] answer = null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private String picture = null;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public void setQuestion(String ques){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.question = ques;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public void setAnswer(String[] answer){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.answer = answer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; public String getQuestion(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return this.question;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public String[] getAnswer(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return this.answer;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public void setPicture(String picture){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.picture = picture;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public String getPicture(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return this.picture;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</div>
3、
<div class="t_msgfont" id="message466024">XML <br />
<br />
<br />
<br />
&lt;?xml version="1.0" encoding="GB2312" ?&gt; <br />
&lt;root&gt;<br />
&lt;resume1&gt;<br />
&lt;qa id="01"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题：我的PDA不能联结到灵视系统服务器。<br />
&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答：请检查是否已经播号联结（移动用户拨，联通用户拨#777，小灵通用户拨ISP服务号码）。<br />
&lt;/answer&gt;&nbsp;&nbsp;<br />
&lt;/qa&gt;&nbsp;&nbsp;<br />
&lt;qa id="02"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题：我的PC不能联结到灵视系统服务器。ssssss<br />
&nbsp; &nbsp;&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答：请确认；<br />
&nbsp; &nbsp; &nbsp; &nbsp; 1. 网线已连接且工作正常。<br />
&nbsp; &nbsp; &nbsp; &nbsp; 2. MPEG-4_Player目录下Decoder.ini文件中ip地址和端口号是否正确。<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/answer&gt;&nbsp;&nbsp;<br />
&lt;/qa&gt;&nbsp; &nbsp;<br />
&lt;qa id="03"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题:&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答1:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答2:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答3:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答4:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答5:&lt;/answer&gt;<br />
&nbsp; &nbsp;&lt;pic file="jiejuefangan-1.jpg"/&gt; <br />
&lt;/qa&gt;&nbsp; &nbsp;<br />
&lt;qa id="04"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题:&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答:&lt;/answer&gt;&nbsp;&nbsp;<br />
&lt;/qa&gt;&nbsp; &nbsp;<br />
&lt;/resume1&gt; <br />
<br />
&lt;resume2&gt;<br />
&lt;qa id="01"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题:&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答:&lt;/answer&gt;&nbsp;&nbsp;<br />
&lt;/qa&gt;&nbsp;&nbsp;<br />
&lt;qa id="02"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题:&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答:&lt;/answer&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答1:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答2:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答3:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答4:&lt;/answer&gt;&nbsp;&nbsp;<br />
&nbsp; &nbsp;&lt;answer&gt;回答5:&lt;/answer&gt; <br />
&lt;/qa&gt;&nbsp; &nbsp;<br />
&lt;qa id="03"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题:&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答:&lt;/answer&gt;&nbsp;&nbsp;<br />
&lt;/qa&gt;&nbsp; &nbsp;<br />
&lt;qa id="04"&gt;<br />
&nbsp; &nbsp;&lt;question&gt;问题:&lt;/question&gt; <br />
&nbsp; &nbsp;&lt;answer&gt;回答:&lt;/answer&gt;&nbsp;&nbsp;<br />
&lt;/qa&gt;&nbsp; &nbsp;<br />
&lt;/resume2&gt; <br />
&lt;/root&gt;</div>
<br />
<br />
</span></span>
 <img src ="http://www.blogjava.net/tunaic/aggbug/271316.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-05-18 13:47 <a href="http://www.blogjava.net/tunaic/archive/2009/05/18/271316.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat配置为系统服务</title><link>http://www.blogjava.net/tunaic/archive/2009/03/18/260396.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Wed, 18 Mar 2009 02:48:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/03/18/260396.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/260396.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/03/18/260396.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/260396.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/260396.html</trackback:ping><description><![CDATA[<div class="articleContent" id="articleBody"><strong><strong>操作步骤：</strong> <br />1、在&#8220;<strong>开始</strong>&#8221;&#8594;&#8220;<strong>运行</strong>&#8221;中输入cmd 命令，进入MS-DOS界面 <br />2、cd 到tomcat的bin目录下 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C:\&gt; <span style="color: blue"><strong>cd tomcat/bin</strong></span> <br />3、运行命令service install, 就可以把tomcat注册成系统服务了 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c:\tomcat\bin&gt; <span style="color: blue"><strong>service install</strong></span> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 运行命令service uninstall，就可以删除服务。 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c:\tomcat\bin&gt; <strong><span style="color: blue">service uninstall</span></strong> <br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当然，这样注册出来的服务启动类型是手动的；若想设置为开机自动启动，则需要修改bin目录下的service.bat文件。 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 打开此文件,在倒数第三行左右的那句输出 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">echo The service '%SERVICE_NAME%' has been installed.</span> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这句是输出服务安装成功,在这之前加一句 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue">sc config %SERVICE_NAME% start= auto</span> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 就OK了,以后开机后tomcat服务就自动启动了 <br /><strong>备注：</strong> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 启动/停止tomcat服务的命令，如下： <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 启动tomcat服务： c:\tomcat&gt; <span style="color: blue"><strong>net start tomcat6</strong></span> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 停止tomcat服务： c:\tomcat&gt; <span style="color: blue"><strong>net stop tomcat6</strong></span> <br />或者 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 打开&#8220;服务&#8221;对话框下进行手动点击&#8220;启动&#8221;|&#8220;停止&#8221;按钮来操作。<br /><br /><br />
<div class="tit"><span style="color: red">linux+jdk6+tomcat6 </span></div>
<div class="date">&nbsp;</div>
<div style="border-top: #bddaf2 1px solid; margin-bottom: 5px"></div>
<div class="cnt" id="blog_text">
<div style="line-height: 16.5pt"><strong><span style="font-size: 14pt; color: #7030a0">一、安装前的准备和相关说明</span></strong></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">下载</font></span><span>JDK</span><span style="font-size: 9pt"><font face="宋体">，</font></span><span>tomcat<br />&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt"><font face="宋体">我下载的是</font></span><span><br /><span style="color: #7030a0">&nbsp;&nbsp;&nbsp;&nbsp; apache-tomcat-6.0.24.tar.gz <br />&nbsp;&nbsp;&nbsp;&nbsp; jdk-6u18-linux-i586-rpm.bin</span><br />&nbsp;&nbsp;&nbsp;&nbsp; <br /></span><span style="font-size: 9pt"><font face="宋体">查看系统版本</font></span><span><br />[root@www ~]# uname -a <br />Linux <a href="http://www.digican-rfid.com/"><font color="#000000">www.digican-rfid.com</font></a> 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux<br />[root@www ~]#</span></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">相关说明：</font></span><span><br /></span><span style="font-size: 9pt"><font face="宋体">网站目录为：</font></span><span>/data/webapps<br />log</span><span style="font-size: 9pt"><font face="宋体">目录为：</font></span><span>/data/logs<br /><br /><br /></span><strong><span style="font-size: 14pt; color: #7030a0">二、安装JDK</span></strong><span><br />[root@www ~]# cd /software<br />[root@www software]# chmod +x jdk-6u18-linux-i586-rpm.bin<br />[root@www software]# ./jdk-6u18-linux-i586-rpm.bin<br />[root@www software]# vi /etc/profile<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br /></span><span style="font-size: 9pt"><font face="宋体">在</font></span><span>export PATH</span><span style="font-size: 9pt"><font face="宋体">前增加以下内容</font></span><span> <br />JAVA_HOME=/usr/java/jdk1.6.0_18<br />export JAVA_HOME<br />PATH=$JAVA_HOME/bin:$PATH<br />CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar<br />CATALINA_HOME=/usr/local/tomcat6<br />PATH=$PATH:/usr/local/tomcat6/bin/<br /></span><span style="font-size: 9pt"><font face="宋体">在</font></span><span>export PATH </span><span style="font-size: 9pt"><font face="宋体">的后面增加以下内容</font></span><span><br />JAVA_HOME CLASSPATH CATALINA_HOME<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />[root@www software]# set&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt"><font face="宋体">查看输出中有没有</font></span><span>java</span><span style="font-size: 9pt"><font face="宋体">的变量</font></span><span><br />[root@www software]# java -version </span><span style="font-size: 9pt"><font face="宋体">测试</font></span><span>java</span></div>
<div style="line-height: 16.5pt"></div>
<div style="line-height: 16.5pt"><strong><span style="font-size: 14pt; color: #7030a0">三、安装tomcat</span></strong><span><br />[root@www software]# chmod +x apache-tomcat-6.0.24.tar.gz<br />[root@www software]# cd /usr/local<br />[root@www local]# tar -xzvf /software/apache-tomcat-6.0.24.tar.gz<br />[root@www local]# ln -s apache-tomcat-6.0.24 tomcat6<br />[root@www local]# cd tomcat6<br />[root@www tomcat6]# vi /etc/profile<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br /></span><span style="font-size: 9pt"><font face="宋体">在</font></span><span>export PATH</span><span style="font-size: 9pt"><font face="宋体">前增加以下内容</font></span><span> <br />CATALINA_HOME=/usr/local/tomcat6<br />CATALINA_BASE=/usr/local/tomcat6<br />PATH=$PATH:/usr/local/tomcat6/bin/<br /></span><span style="font-size: 9pt"><font face="宋体">在</font></span><span>export PATH </span><span style="font-size: 9pt"><font face="宋体">的后面增加以下内容</font></span><span><br />CATALINA_HOME CATALINA_BASE<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />[root@www tomcat6]# set&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt"><font face="宋体">查看输出中有没有</font></span><span>java</span><span style="font-size: 9pt"><font face="宋体">的变量</font></span><span><br />[root@www tomcat6]# startup.sh </span><span style="font-size: 9pt"><font face="宋体">启动</font></span><span>tomcat<br />[root@www tomcat6]# netstat -ln | grep 80 </span><span style="font-size: 9pt"><font face="宋体">要保证出现下面一行</font></span><span>&nbsp;&nbsp;&nbsp; <br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 :::8080&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :::*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp; <br /></span><span style="font-size: 9pt"><font face="宋体">在浏览器里输入</font></span><span> <a href="http://localhsot:8080/"><font color="#000000">http://localhsot:8080</font></a> </span><span style="font-size: 9pt"><font face="宋体">应该会出来</font></span><span>tomcat</span><span style="font-size: 9pt"><font face="宋体">的标志</font></span><span><br />[root@www tomcat6]# shutdown.sh </span><span style="font-size: 9pt"><font face="宋体">停止</font></span><span>tomcat<br />[root@www tomcat6]# vi conf/server.xml </span><span style="font-size: 9pt"><font face="宋体">更改以下几行</font></span><span><br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />&nbsp;&nbsp;&nbsp; &lt;Engine name="Catalina" defaultHost="<a href="http://www.digican-rfid.com/"><font color="#000000">www.digican-rfid.com</font></a>"&gt;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt"><font face="宋体">更改默认主机</font></span><span><br />&nbsp;&nbsp;&nbsp; <br />&lt;Host name="<a href="http://www.digican-rfid.com/"><font color="#000000">www.digican-rfid.com</font></a>" appBase="/data/webapps"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unpackWARs="true" autoDeploy="true"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlValidation="false" xmlNamespaceAware="false"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Context path="" docBase="/data/webapps/company" reloadable="true" caseSensitive="false" debug="0"/&gt; </span><span style="font-size: 9pt"><font face="宋体">更改主机头和网站目录</font></span><span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Connector port="80" protocol="HTTP/1.1" <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connectionTimeout="20000" <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; redirectPort="8443" /&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt"><font face="宋体">更改端口</font></span><span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></div>
<div style="line-height: 16.5pt"></div>
<div style="line-height: 16.5pt"><span>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span></div>
<div style="line-height: 16.5pt"><span><br />[root@www tomcat6]# vi conf/tomcat-users.xml </span><span style="font-size: 9pt"><font face="宋体">更改以下几行</font></span><span><br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />&lt;user username="tomcat" password="admin" roles="admin,manager"/&gt; </span><span style="font-size: 9pt"><font face="宋体">增加</font></span><span>tomcat</span><span style="font-size: 9pt"><font face="宋体">管理用户</font></span><span><br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />[root@www tomcat6]# mkdir -pv /data/logs<br />[root@www tomcat6]# cp -R /usr/local/tomcat6/webapps /data<br />[root@www tomcat6]# rm -rf /usr/local/tomcat6/webapps<br />[root@www tomcat6]# ln -s /data/webapps /usr/local/tomcat6/webapps<br />[root@www tomcat6]# startup.sh </span><span style="font-size: 9pt"><font face="宋体">启动</font></span><span>tomcat<br />[root@www tomcat6]# netstat -ln | grep 80 </span><span style="font-size: 9pt"><font face="宋体">要保证出现下面一行</font></span><span>&nbsp;&nbsp;&nbsp; <br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 :::80&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :::*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LISTEN&nbsp;&nbsp;&nbsp; <br /></span><span style="font-size: 9pt"><font face="宋体">在浏览器里输入</font></span><span> <a href="http://localhsot/"><font color="#000000">http://localhsot</font></a> </span><span style="font-size: 9pt"><font face="宋体">应该会出来自定义的网站</font></span><span><br />[root@www tomcat6]# shutdown.sh </span><span style="font-size: 9pt"><font face="宋体">停止</font></span><span>tomcat<br />[root@www tomcat6]# </span></div>
<div style="line-height: 16.5pt"><span>tomcat</span><font face="宋体"><span style="font-size: 9pt">安装完成</span></font></div>
<div style="line-height: 16.5pt"><strong><span style="font-size: 14pt; color: #7030a0">四、设置tomcat开机自启动</span></strong></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">以下文章参考了网上的文章，但经过自己试验和整理。</font></span><span> <br />linux</span><span style="font-size: 9pt"><font face="宋体">自动启动程序的方法很多，但是有时某些程序要设置环境变量的就会引起麻烦。</font></span><span><br />tomcat</span><span style="font-size: 9pt"><font face="宋体">启动时需要设置</font></span><span>JAVA_HOME,CLASSPATH</span><span style="font-size: 9pt"><font face="宋体">等环境变量，</font></span><span><br /></span><span style="font-size: 9pt"><font face="宋体">很多文章说设置好环境变量，把</font></span><span>/path/startup.sh</span><span style="font-size: 9pt"><font face="宋体">放到</font></span><span>rc.local</span><span style="font-size: 9pt"><font face="宋体">中就可以实现自动启动了，</font></span><span><br /></span><span style="font-size: 9pt"><font face="宋体">但是实际操作发现，很多的</font></span><span>linux</span><span style="font-size: 9pt"><font face="宋体">版本因为安全原因，</font></span><span>rc.local</span><span style="font-size: 9pt"><font face="宋体">中忽略了</font></span><span>export</span><span style="font-size: 9pt"><font face="宋体">命令，也就是说在这里设置的</font></span><span>export</span><span style="font-size: 9pt"><font face="宋体">都是无效的，同时，放在</font></span><span>rc.local</span><span style="font-size: 9pt"><font face="宋体">中默认会以</font></span><span>root</span><span style="font-size: 9pt"><font face="宋体">用户运行，只要在远程运行一个</font></span><span>jsp</span><font face="宋体"><span style="font-size: 9pt">文件就可能会删除系统文件，是极不安全的方式。</span></font></div>
<div style="line-height: 16.5pt"></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">以下方法经过我的验证</font></span><span>,</span><font face="宋体"><span style="font-size: 9pt">可以实现。</span></font></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">在</font></span><span>Linux</span><span style="font-size: 9pt"><font face="宋体">下，</font></span><span>Tomcat</span><span style="font-size: 9pt"><font face="宋体">可以作为一个守护进程来启动以及停止，这个必须借助于项目</font></span><span>commons-daemon</span><span style="font-size: 9pt"><font face="宋体">中的</font></span><span>jsvc</span><span style="font-size: 9pt"><font face="宋体">工具。</font></span><span>Tomcat</span><span style="font-size: 9pt"><font face="宋体">安装完后就带有这个工具的源码</font></span><span>{tomcat}/bin/jsvc.tar.gz</span><span style="font-size: 9pt"><font face="宋体">。按照下列命令安装这个工具：</font></span><span><br />[root@www ~]# cd /usr/local/tomcat6/bin/<br />[root@www bin]# tar zxvf /usr/local/tomcat6/bin/jsvc.tar.gz<br />[root@www bin]# cd jsvc-src<br />[root@www jsvc-src]# chmod +x configure<br />[root@www jsvc-src]# ./configure --with-java=/usr/java/jdk1.6.0_18/<br />[root@www jsvc-src]# make<br />[root@www jsvc-src]# ./jsvc -help</span></div>
<div style="line-height: 16.5pt"><span>jsvc</span><span style="font-size: 9pt"><font face="宋体">工具本身带了一个脚本（在</font></span><span>native</span><span style="font-size: 9pt"><font face="宋体">目录下</font></span><span>)</span><span style="font-size: 9pt"><font face="宋体">用来启动和停止</font></span><span>Tomcat</span><span style="font-size: 9pt"><font face="宋体">守护进程，但是在试验中发现该脚本无法设置为自动启动，显示的错误信息是：</font></span><span>tomcat </span><span style="font-size: 9pt"><font face="宋体">服务不支持</font></span><span> chkconfig</span><span style="font-size: 9pt"><font face="宋体">，因此修改了此脚本，可以从此处下载：</font></span><span>tomcat.txt<br /></span><span style="font-size: 9pt"><font face="宋体">程序代码</font></span><span>:</span><span style="font-size: 9pt"><font face="宋体">（网上大部分代码有错误，经修改运行</font></span><span>OK</span><font face="宋体"><span style="font-size: 9pt">）</span></font></div>
<div style="line-height: 16.5pt"><span><br />[root@www jsvc-src]# tar -xzvf bin/jsvc.tar.gz<br />[root@www jsvc-src]# cp /usr/local/tomcat6/bin/jsvc-src/native/Tomcat5.sh /etc/rc.d/init.d/tomcatd<br />[root@www jsvc-src]# useradd tomcat<br />[root@www jsvc-src]# chown -R tomcat /usr/local/tomcat6<br />[root@www jsvc-src]# vi /etc/rc.d/init.d/tomcatd<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />#!/bin/sh<br />##############################################################################<br />#<br />#&nbsp;&nbsp; Copyright 2004 The Apache Software Foundation.<br />#<br />#&nbsp;&nbsp; Licensed under the Apache License, Version 2.0 (the "License");<br />#&nbsp;&nbsp; you may not use this file except in compliance with the License.<br />#&nbsp;&nbsp; You may obtain a copy of the License at<br />#<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.apache.org/licenses/LICENSE-2.0"><font color="#000000">http://www.apache.org/licenses/LICENSE-2.0</font></a><br />#<br />#&nbsp;&nbsp; Unless required by applicable law or agreed to in writing, software<br />#&nbsp;&nbsp; distributed under the License is distributed on an "AS IS" BASIS,<br />#&nbsp;&nbsp; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br />#&nbsp;&nbsp; See the License for the specific language governing permissions and<br />#&nbsp;&nbsp; limitations under the License.<br />##############################################################################<br />#<br /># Small shell script to show how to start/stop Tomcat using jsvc<br /># If you want to have Tomcat running on port 80 please modify the server.xml<br /># file:<br />#<br />#&nbsp;&nbsp;&nbsp; &lt;!-- Define a non-SSL HTTP/1.1 Connector on port 80 --&gt;<br />#&nbsp;&nbsp;&nbsp; &lt;Connector className="org.apache.catalina.connector.http.HttpConnector"<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; port="80" minProcessors="5" maxProcessors="75"<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enableLookups="true" redirectPort="8443"<br />#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acceptCount="10" debug="0" connectionTimeout="60000"/&gt;<br />#<br /># That is for Tomcat-6.0.x (Apache Tomcat/6.0)<br />#<br />#<br />#chkconfig:345 87 13<br />#description: Tomcat Daemon<br />#</span><span style="font-size: 9pt"><font face="宋体">以上两行是</font></span><span>chkconfig </span><span style="font-size: 9pt"><font face="宋体">用的，如果没有，</font></span><span>chkconfig </span><span style="font-size: 9pt"><font face="宋体">就不支持此服务</font></span><span><br /># processname: jsvc<br /># pidfile: /var/run/jsvc.pid<br />prog=tomcat</span></div>
<div style="line-height: 16.5pt"><span># Adapt the following lines to your configuration<br />JAVA_HOME=/usr/java/jdk1.6.0_18<br />CATALINA_HOME=/usr/local/tomcat6<br />DAEMON_HOME=$CATALINA_HOME/bin</span></div>
<div style="line-height: 16.5pt"><span>TOMCAT_USER=tomcat</span></div>
<div style="line-height: 16.5pt"><span># for multi instances adapt those lines.<br />TMP_DIR=/tmp<br />CATALINA_OPTS=<br />PID_FILE=/var/run/jsvc.pid<br />CATALINA_BASE=$CATALINA_HOME</span></div>
<div style="line-height: 16.5pt"><span>#CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"<br />CLASSPATH=$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar</span></div>
<div style="line-height: 16.5pt"><span>#case "$1" in<br />start(){<br />&nbsp;&nbsp;&nbsp;&nbsp; echo -n "Starting $prog: "<br />&nbsp;&nbsp;&nbsp; #<br />&nbsp;&nbsp;&nbsp; # Start Tomcat<br />&nbsp;&nbsp;&nbsp; #<br />#&nbsp;&nbsp; $DAEMON_HOME/src/native/unix/jsvc \<br />&nbsp;&nbsp;&nbsp; $DAEMON_HOME/jsvc-src/jsvc \<br />&nbsp;&nbsp;&nbsp; -user $TOMCAT_USER \<br />&nbsp;&nbsp;&nbsp; -home $JAVA_HOME \<br />&nbsp;&nbsp;&nbsp; -Dcatalina.home=$CATALINA_HOME \<br />&nbsp;&nbsp;&nbsp; -Djava.io.tmpdir=$TMP_DIR \<br />&nbsp;&nbsp;&nbsp; -pidfile $PID_FILE \<br />&nbsp;&nbsp;&nbsp; -outfile $CATALINA_HOME/logs/catalina.out \<br />&nbsp;&nbsp;&nbsp; -errfile '&amp;1' \<br />&nbsp;&nbsp;&nbsp; $CATALINA_OPTS \<br />&nbsp;&nbsp;&nbsp; -cp $CLASSPATH \<br />&nbsp;&nbsp;&nbsp; org.apache.catalina.startup.Bootstrap<br />&nbsp;&nbsp;&nbsp; #<br />&nbsp;&nbsp;&nbsp; # To get a verbose JVM<br />&nbsp;&nbsp;&nbsp; #-verbose \<br />&nbsp;&nbsp;&nbsp; # To get a debug of jsvc.<br />&nbsp;&nbsp;&nbsp; #-debug \<br />&nbsp;&nbsp; RETVAL=$?<br />[ $RETVAL = 0 ] &amp;&amp; touch /var/lock/subsys/jsvc<br />[ $RETVAL = 0 ] &amp;&amp; echo success || echo failure<br />echo return $RETVAL<br />}<br />stop(){<br />&nbsp;&nbsp;&nbsp;&nbsp; echo -n "Stopping $prog: "<br />&nbsp;&nbsp;&nbsp; #<br />&nbsp;&nbsp;&nbsp; # Stop Tomcat<br />&nbsp;&nbsp;&nbsp; #<br />&nbsp;&nbsp;&nbsp; PID=`cat /var/run/jsvc.pid`<br />&nbsp;&nbsp;&nbsp; kill $PID<br />&nbsp;&nbsp;&nbsp; RETVAL=$?<br />&nbsp;&nbsp;&nbsp; [ $RETVAL=0 ] &amp;&amp; rm /var/lock/subsys/jsvc<br />&nbsp;&nbsp;&nbsp; [ $RETVAL=0 ] &amp;&amp; echo success || echo failure<br />&nbsp;&nbsp;&nbsp; echo <br />&nbsp;&nbsp;&nbsp; return $RETVAL<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; case "$1" in<br />&nbsp;&nbsp;&nbsp; start)<br />&nbsp;&nbsp;&nbsp; start<br />&nbsp;&nbsp;&nbsp; ;;<br />&nbsp;&nbsp;&nbsp; stop)<br />&nbsp;&nbsp;&nbsp; stop<br />&nbsp;&nbsp;&nbsp; ;;<br />&nbsp;&nbsp;&nbsp; *)<br />&nbsp;&nbsp;&nbsp; echo "Usage $0 start/stop"<br />&nbsp;&nbsp;&nbsp; exit 1;;<br />&nbsp;&nbsp;&nbsp; esac<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span></div>
<div style="line-height: 16.5pt"><span>[root@www ~]# chmod +x /etc/rc.d/init.d/tomcatd</span></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">来验证守护进程是否可以正常启动和停止。</font></span><span><br />[root@www ~]# /etc/rc.d/init.d/tomcat start|stop </span><span style="font-size: 9pt"><font face="宋体">启动或停止</font></span><span>tomcat<br /></span><span style="font-size: 9pt"><font face="宋体">或</font></span><span><br />[root@www ~]# service tomcat start|stop </span></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">接下来就是把这个脚本设置成系统启动时自动执行，系统关闭时自动停止，使用如下命令：</font></span><span><br />[root@www ~]# chkconfig --add tomcatd</span></div>
<div style="line-height: 16.5pt"><span style="font-size: 9pt"><font face="宋体">重新启动系统后可以启动的过程中看到</font></span><span>Starting Tomcat ..... [OK]</span><font face="宋体"><span style="font-size: 9pt">的信息，这样就完成设置过程。</span></font></div></div></strong></div><img src ="http://www.blogjava.net/tunaic/aggbug/260396.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-03-18 10:48 <a href="http://www.blogjava.net/tunaic/archive/2009/03/18/260396.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts hibernate spring整合总结</title><link>http://www.blogjava.net/tunaic/archive/2009/02/11/254290.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Wed, 11 Feb 2009 09:51:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2009/02/11/254290.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/254290.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2009/02/11/254290.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/254290.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/254290.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1&nbsp; Struts+Spring主要就是让Struts知道Spring的存在，我们可以采用两种办法。（1） 运用Struts的插件方法，添加struts-congif.xml的&lt;plug-in&gt;节点。示例代码如下：1&lt;plug-in&nbsp;className="org.springframework.web.struts.ContextLoaderP...&nbsp;&nbsp;<a href='http://www.blogjava.net/tunaic/archive/2009/02/11/254290.html'>阅读全文</a><img src ="http://www.blogjava.net/tunaic/aggbug/254290.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2009-02-11 17:51 <a href="http://www.blogjava.net/tunaic/archive/2009/02/11/254290.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat 配置集锦</title><link>http://www.blogjava.net/tunaic/archive/2008/09/27/231527.html</link><dc:creator>三羽</dc:creator><author>三羽</author><pubDate>Sat, 27 Sep 2008 08:13:00 GMT</pubDate><guid>http://www.blogjava.net/tunaic/archive/2008/09/27/231527.html</guid><wfw:comment>http://www.blogjava.net/tunaic/comments/231527.html</wfw:comment><comments>http://www.blogjava.net/tunaic/archive/2008/09/27/231527.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tunaic/comments/commentRss/231527.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tunaic/services/trackbacks/231527.html</trackback:ping><description><![CDATA[<span class="content"><font color="#000000">1.下载</font><a href="http://www.eu.apache.org/dist/jakarta/tomcat-5/" target="_blank"><font color="#000000">http://www.eu.apache.org/dist/jakarta/tomcat-5/</font></a><font color="#000000"> <br />
这里注意，在jakarta-tomcat-5.0.28.exe以前是有默认的admin模块，在jakarta-tomcat-5.5.9.exe则没<br />
有安装默认的admin模块，这时</font><a href="http://127.0.0.1:8080/admin" target="_blank"><font color="#000000">http://127.0.0.1:8080/admin</font></a><font color="#000000">打开时则会出现 Tomcat's administration web application is no longer installed by default. Download and install the "admin" package to use it. <br />
因此我们现在需要下载"admin"package 包， 把jakarta-tomcat-5.5.x.zip 与 jakarta-tomcat-5.5.x-compat.zip 与 jakarta-tomcat-5.5.x-admin.zip 三个文件解压在同一个目录中 (如果使用jdk1.4，才需<br />
要compat.zip用jdk1.5就可以免了这个。) <br />
2.修改jakarta-tomcat-5.5.x\conf\tomcat-users.xml. <br />
添加管理员账号lizongbo，密码为lizongbopass. <br />
新xml如下： <br />
&lt;?xml version='1.0' encoding='utf-8'?&gt; <br />
&lt;tomcat-users&gt; <br />
&lt;role rolename="tomcat"/&gt; <br />
&lt;role rolename="role1"/&gt; <br />
&lt;role rolename="manager"/&gt; <br />
&lt;role rolename="admin"/&gt; <br />
&lt;user username="tomcat" password="tomcat" roles="tomcat"/&gt; <br />
&lt;user username="role1" password="tomcat" roles="role1"/&gt; <br />
&lt;user username="both" password="tomcat" roles="tomcat,role1"/&gt; <br />
&lt;user username="lizongbo" password="lizongbopass" roles="admin,manager"/&gt; <br />
&lt;/tomcat-users&gt; <br />
有时在%CATALINA_HOME%\server\webapps\admin\WEB-INF\web.xml里面也要做些修改 <br />
&lt;!-- Security is active on entire directory --&gt; <br />
&lt;security-constraint&gt; <br />
&lt;display-name&gt;Tomcat Server Configuration Security Constraint&lt;/display-name&gt; <br />
&lt;web-resource-collection&gt; <br />
&lt;web-resource-name&gt;Protected Area&lt;/web-resource-name&gt; <br />
&lt;!-- Define the context-relative URL(s) to be protected --&gt; <br />
&lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt; <br />
&lt;url-pattern&gt;*.do&lt;/url-pattern&gt; <br />
&lt;url-pattern&gt;*.html&lt;/url-pattern&gt; <br />
&lt;/web-resource-collection&gt; <br />
&lt;auth-constraint&gt; <br />
&lt;!-- Anyone with one of the listed roles may access this area --&gt; <br />
&lt;role-name&gt;admin&lt;/role-name&gt; <br />
&lt;/auth-constraint&gt; <br />
&lt;/security-constraint&gt; <br />
&lt;!-- Login configuration uses form-based authentication --&gt; <br />
&lt;login-config&gt; <br />
&lt;auth-method&gt;FORM&lt;/auth-method&gt; <br />
&lt;realm-name&gt;Tomcat Server Configuration Form-Based Authentication Area&lt;/realm-name&gt; <br />
&lt;form-login-config&gt; <br />
&lt;form-login-page&gt;/login.jsp&lt;/form-login-page&gt; <br />
&lt;form-error-page&gt;/error.jsp&lt;/form-error-page&gt; <br />
&lt;/form-login-config&gt; <br />
&lt;/login-config&gt; <br />
&lt;!-- Security roles referenced by this web application --&gt; <br />
&lt;security-role&gt; <br />
&lt;description&gt; <br />
The role that is required to log in to the Administration Application <br />
&lt;/description&gt; <br />
&lt;role-name&gt;admin&lt;/role-name&gt; <br />
&lt;/security-role&gt; <br />
无论是 Authetication ( 身份验证 还是 Authorization ( 权限管控 都只有设置相关的 admin ROLE, 当<br />
你想要新增或修改相关的 AA, 就必须修改这一个文件, 来符合你的环境. <br />
3.修改jakarta-tomcat-5.5.x\conf\server.xml来解决编码问题。 <br />
(给Connector 添加URIEncoding参数，参考</font><a href="http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx" target="_blank"><font color="#000000">http://blog.csdn.net/darkxie/archive/2004/10/25/TOMCATAPP.aspx</font></a><font color="#000000">) <br />
(可以设置成GB18030) <br />
&lt;Connector port="8080" <br />
maxThreads="150" minSpareThreads="25" maxSpareThreads="75" <br />
enableLookups="false" redirectPort="8443" acceptCount="200" <br />
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK" <br />
compression="on" compressionMinSize="2048" <br />
noCompressionUserAgents="gozilla, traviata" <br />
compressableMimeType="text/html,text/xml"/&gt; <br />
&lt;Connector port="8009" <br />
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" URIEncoding="GBK"/&gt; <br />
4.启用支持gzip压缩. <br />
(</font><a href="http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&amp;i=81169" target="_blank"><font color="#000000">http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&amp;i=81169</font></a><font color="#000000">) <br />
添加下列属性 <br />
compression="on" <br />
compressionMinSize="2048" <br />
noCompressionUserAgents="gozilla, traviata" <br />
compressableMimeType="text/html,text/xml" <br />
5.设置虚拟主机。 <br />
在jakarta-tomcat-5.5.x\下建立文件夹vhost\</font><a href="http://www.mydomain.com/" target="_blank"><font color="#000000">www.mydomain.com</font></a><font color="#000000">。 <br />
然后修改jakarta-tomcat-5.5.x\conf\server.xml <br />
&lt;Engine defaultHost="localhost" name="Catalina"&gt; <br />
&lt;Host appBase="vhost/www.mydomain.com" name="</font><a href="http://www.mydomain.com/" target="_blank"><font color="#000000">http://www.mydomain.com/</font></a><font color="#000000">"&gt; <br />
&lt;/Host&gt; <br />
&lt;Host appBase="webapps" name="localhost"&gt; <br />
&lt;/Host&gt; <br />
&lt;Realm className="org.apache.catalina.realm.UserDatabaseRealm"/&gt; <br />
&lt;/Engine&gt; <br />
6.添加数据库驱动,更新mail.jar和actiovation.jar <br />
复制mysql-connector-java-3.0.16-ga-bin.jar,pg74.215.jdbc3.jar到 jakarta-tomcat-5.5.x\common\lib\ <br />
还有javamail 1.3.2的mail.jar，jaf-1_0_2的 activation.jar <br />
msSQl 2000 JDBC sp3，msbase.jar,msutil,jar,mssqlserver.jar <br />
7.配置SSL <br />
参考 </font><a href="http://jakarta.apache.org/tomcat/tomcat-5.5-doc/ssl-howto.html" target="_blank"><font color="#000000">http://jakarta.apache.org/tomcat/tomcat-5.5-doc/ssl-howto.html</font></a><font color="#000000"> <br />
D:\j2sdk1.4.2_06\bin&gt;%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA <br />
输入keystore密码： lizongbossl <br />
您的名字与姓氏是什么？ <br />
[tomcat5.5.x]： tomcat5.5.x <br />
您的组织单位名称是什么？ <br />
[jakarta]： jakarta <br />
您的组织名称是什么？ <br />
[apache]： apache <br />
您所在的城市或区域名称是什么？ <br />
[hzcity]： hzcity <br />
您所在的州或省份名称是什么？ <br />
[gdp]： gdp <br />
该单位的两字母国家代码是什么 <br />
[CN]： CN <br />
CN=tomcat5.5.x, OU=jakarta, O=apache, L=hzcity, ST=gdp, C=CN 正确吗？ <br />
[否]： y <br />
输入&lt;tomcat&gt;的主密码 <br />
（如果和 keystore 密码相同，按回车）： <br />
(必须密码一致，因此直接回车) <br />
然后再把userhome(例如：C:\Documents and Settings\lizongbo\)下的.keystore复制到 <br />
tomcat的conf\目录下。 <br />
(例如：D:\jakarta-tomcat-5.5.x\conf\.keystore <br />
配置jakarta-tomcat-5.5.x\conf\server.xml <br />
加上 <br />
&lt;Connector port="8443" <br />
maxThreads="150" minSpareThreads="25" maxSpareThreads="75" <br />
enableLookups="false" disableUploadTimeout="true" <br />
acceptCount="100" scheme="https" secure="true" <br />
clientAuth="false" sslProtocol="TLS" <br />
keystoreFile="conf/.keystore" <br />
keystorePass="lizongbossl"&gt; &lt;!--与先前设置的密码一致--&gt; <br />
&lt;/Connector&gt; <br />
8.禁止文件目录列表， <br />
修改jakarta-tomcat-5.5.x\conf\web.xml，把listing设置为false <br />
&lt;servlet&gt; <br />
&lt;servlet-name&gt;default&lt;/servlet-name&gt; <br />
&lt;servlet-class&gt;org.apache.catalina.servlets.DefaultServlet&lt;/servlet-class&gt; <br />
&lt;init-param&gt; <br />
&lt;param-name&gt;debug&lt;/param-name&gt; <br />
&lt;param-value&gt;0&lt;/param-value&gt; <br />
&lt;/init-param&gt; <br />
&lt;init-param&gt; <br />
&lt;param-name&gt;listings&lt;/param-name&gt; <br />
&lt;param-value&gt;true&lt;/param-value&gt; <br />
&lt;/init-param&gt; <br />
&lt;load-on-startup&gt;1&lt;/load-on-startup&gt; <br />
&lt;/servlet&gt; <br />
9.指定了自己的javaEncoding <br />
(参考 </font><a href="http://gceclub.sun.com.cn/staticcontent/html/sunone/app7/app7-dg-webapp/ch6/ch6-4.html" target="_blank"><font color="#000000">http://gceclub.sun.com.cn/staticcontent/html/sunone/app7/app7-dg-webapp/ch6/ch6-4.html</font></a><font color="#000000"> <br />
&lt;servlet&gt; <br />
&lt;servlet-name&gt;jsp&lt;/servlet-name&gt; <br />
&lt;servlet-class&gt;org.apache.jasper.servlet.JspServlet&lt;/servlet-class&gt; <br />
&lt;init-param&gt; <br />
&lt;param-name&gt;fork&lt;/param-name&gt; <br />
&lt;param-value&gt;false&lt;/param-value&gt; <br />
&lt;/init-param&gt; <br />
&lt;init-param&gt; <br />
&lt;param-name&gt;javaEncoding&lt;/param-name&gt; <br />
&lt;param-value&gt;GB18030&lt;/param-value&gt; <br />
&lt;/init-param&gt; <br />
&lt;init-param&gt; <br />
&lt;param-name&gt;xpoweredBy&lt;/param-name&gt; <br />
&lt;param-value&gt;true&lt;/param-value&gt; <br />
&lt;/init-param&gt; <br />
&lt;load-on-startup&gt;3&lt;/load-on-startup&gt; <br />
&lt;/servlet&gt; <br />
10.添加rar,iso等的mime-type映射 <br />
避免在浏览器里直接打开。 <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;mht&lt;/extension&gt; <br />
&lt;mime-type&gt;text/x-mht&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;rar&lt;/extension&gt; <br />
&lt;mime-type&gt;application/octet-stream&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;iso&lt;/extension&gt; <br />
&lt;mime-type&gt;application/octet-stream&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;ape&lt;/extension&gt; <br />
&lt;mime-type&gt;application/octet-stream&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;rmvb&lt;/extension&gt; <br />
&lt;mime-type&gt;application/octet-stream&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;ico&lt;/extension&gt; <br />
&lt;mime-type&gt;image/x-icon&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
10.1对html静态页面设置编码 <br />
&lt;!-- 修改下面两行以支持静态超文本的自动编码 <br />
--&gt; <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;htm&lt;/extension&gt; <br />
&lt;mime-type&gt;text/html;charset=gb2312&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
&lt;mime-mapping&gt; <br />
&lt;extension&gt;html&lt;/extension&gt; <br />
&lt;mime-type&gt;text/html;charset=gb2312&lt;/mime-type&gt; <br />
&lt;/mime-mapping&gt; <br />
&lt;/web-app&gt; <br />
11.添加welcome-file-list，并调整顺序。 <br />
&lt;welcome-file-list&gt; <br />
&lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt; <br />
&lt;welcome-file&gt;index.html&lt;/welcome-file&gt; <br />
&lt;welcome-file&gt;index.htm&lt;/welcome-file&gt; <br />
&lt;welcome-file&gt;default.html&lt;/welcome-file&gt; <br />
&lt;welcome-file&gt;default.htm&lt;/welcome-file&gt; <br />
&lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt; <br />
&lt;/welcome-file-list&gt; <br />
</font></span><!-- 正文end --><br />
12.环境变量影响tomcat启动问题<br />
（1）java_home路径不能有";"号 否则会启动不了。<br />
<!-- 正文end -->（2）java_home = C:\Java\jdk1.6.0_11<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classpath&nbsp;&nbsp;&nbsp; = C:\Java\jdk1.6.0_11\lib;C:\Java\jdk1.6.0_11\jre\lib<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = .;C:\Java\jdk1.6.0_11\bin&nbsp;<br />
（3）tomcat 解压版调jvm：在catalina.bat中加入：set JAVA_OPTS= -XX:PermSize=128m -XX:MaxPermSize=256m -Xms400m -Xmx400m；安装版在 tomcat6w.exe的java标签中加入-XX:MaxNewSize=256m<br />
-XX:MaxPermSize=256m&nbsp; 并设置其pool等参数。eclipse设置方法在java--jvm中加入：-Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m<br />
<br />
<br />
13.将程序启动的控制台输出成文本<br />
在startup.bat 后面end前加下面内容<br />
call "%EXECUTABLE%" run %CMD_LINE_ARGS% &gt;&gt; ..\logs\catalina.txt 
<img src ="http://www.blogjava.net/tunaic/aggbug/231527.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tunaic/" target="_blank">三羽</a> 2008-09-27 16:13 <a href="http://www.blogjava.net/tunaic/archive/2008/09/27/231527.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>