﻿<?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>IT博客-咚咚咚-文章分类-Junit &amp; Eclipse</title><link>http://www.cnitblog.com/tab1002/category/1738.html</link><description>静静聆听内心世界的声音　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　
常常有令人欢喜的旋律响起




　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　可以简单、可以深沉





　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　可以抒情、可以喧哗</description><language>zh-cn</language><lastBuildDate>Tue, 27 Sep 2011 04:04:16 GMT</lastBuildDate><pubDate>Tue, 27 Sep 2011 04:04:16 GMT</pubDate><ttl>60</ttl><item><title>struts常见问题：HTTP Status 404 </title><link>http://www.cnitblog.com/tab1002/articles/6208.html</link><dc:creator>咚咚咚</dc:creator><author>咚咚咚</author><pubDate>Tue, 17 Jan 2006 02:35:00 GMT</pubDate><guid>http://www.cnitblog.com/tab1002/articles/6208.html</guid><wfw:comment>http://www.cnitblog.com/tab1002/comments/6208.html</wfw:comment><comments>http://www.cnitblog.com/tab1002/articles/6208.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/tab1002/comments/commentRss/6208.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/tab1002/services/trackbacks/6208.html</trackback:ping><description><![CDATA[<H1><FONT color=#3333ff size=3>在部署Struts时，出现如下错误信息：</FONT></H1>
<H1><FONT color=#ff0000 size=5>HTTP Status 404 - Servlet action is not available</FONT></H1><FONT color=#ff0000>
<HR noShade SIZE=1>
</FONT>
<P><FONT color=#ff0000><B><FONT style="BACKGROUND-COLOR: #525d76">type</FONT></B> Status report</FONT></P>
<P><FONT color=#ff0000><B><FONT style="BACKGROUND-COLOR: #525d76">message</FONT></B> <U>Servlet action is not available</U></FONT></P>
<P><FONT color=#ff0000><B><FONT style="BACKGROUND-COLOR: #525d76">description</FONT></B> <U>The requested resource (Servlet action is not available) is not available.</U></FONT></P>
<P><FONT color=#0033ff>问题原因：</FONT></P>
<P><FONT color=#0033ff>1.、web.xml文件中未配置ActionServlet。</FONT></P>
<P><FONT color=#0033ff>2、struts-config.xml文件未配置你要访问的Action。</FONT></P>
<P><FONT color=#0033ff>3、你的jsp文件form标记中action属性的路径名称错误。</FONT></P>
<P><FONT color=#0033ff>4、非以上三种情况。</FONT></P>
<P><FONT color=#009900><STRONG>针对以上4种情况相应的解决方案如下：</STRONG></FONT></P>
<P><FONT color=#009900><STRONG>1、在web.xml文件中加上ActionServlet的配置信息</STRONG></FONT></P>
<P><FONT color=#009900><SERVLET /><SERVLET /><BR>&nbsp;&nbsp;&nbsp; <SERVLET-NAME />action</SERVLET-NAME /><BR>&nbsp;&nbsp;&nbsp; <SERVLET-CLASS />org.apache.struts.action.ActionServlet</SERVLET-CLASS /><BR>&nbsp;&nbsp;&nbsp; <INIT-PARAM /><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PARAM-NAME />config</PARAM-NAME /><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PARAM-VALUE />/WEB-INF/struts-config.xml</PARAM-VALUE /><BR>&nbsp;&nbsp;&nbsp; </INIT-PARAM /><BR>&nbsp;&nbsp;&nbsp; <INIT-PARAM /><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PARAM-NAME />debug</PARAM-NAME /><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PARAM-VALUE />0</PARAM-VALUE /><BR>&nbsp;&nbsp;&nbsp; </INIT-PARAM /><BR>&nbsp;&nbsp;&nbsp; <INIT-PARAM /><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PARAM-NAME />detail</PARAM-NAME /><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PARAM-VALUE />0</PARAM-VALUE /><BR>&nbsp;&nbsp;&nbsp; </INIT-PARAM /><BR>&nbsp;&nbsp;&nbsp; <LOAD-ON-STARTUP />2</LOAD-ON-STARTUP /><BR>&nbsp; </SERVLET />&nbsp; </SERVLET /></FONT></P>
<P><FONT color=#009900><STRONG>2、在struts-config.xml文件检查你要访问的Action配置文件。</STRONG></FONT></P>
<P><STRONG><FONT color=#009900>3、检查jsp</FONT><FONT color=#009900>文件form标记中action属性的路径名称是否与struts-config.xml文件中action标记的path属性的路径名称一致。</FONT></STRONG></P>
<P><STRONG><FONT color=#009900>4、非以上情况的解决办法就是检查web容器的log日志，如果时tomcat则检查下logs目录下的localhost_log文件，看里边是否记录有错误信息，然后根据错误信息提示将其纠正。</FONT></STRONG></P><img src ="http://www.cnitblog.com/tab1002/aggbug/6208.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/tab1002/" target="_blank">咚咚咚</a> 2006-01-17 10:35 <a href="http://www.cnitblog.com/tab1002/articles/6208.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQLServer2000 JDBC驱动的完整安装及测试说明</title><link>http://www.cnitblog.com/tab1002/articles/6207.html</link><dc:creator>咚咚咚</dc:creator><author>咚咚咚</author><pubDate>Tue, 17 Jan 2006 02:34:00 GMT</pubDate><guid>http://www.cnitblog.com/tab1002/articles/6207.html</guid><wfw:comment>http://www.cnitblog.com/tab1002/comments/6207.html</wfw:comment><comments>http://www.cnitblog.com/tab1002/articles/6207.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/tab1002/comments/commentRss/6207.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/tab1002/services/trackbacks/6207.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; WORD-BREAK: break-all; LINE-HEIGHT: 12pt; TEXT-ALIGN: center; mso-pagination: widow-orphan" align=center><B><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">SQLServer2000 JDBC</SPAN></B><B><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">驱动的完整安装及测试说明</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; WORD-BREAK: break-all; LINE-HEIGHT: 12pt; TEXT-ALIGN: center; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align=center><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">出处</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"> CSDN <BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">一、下载</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">SQLSERVER2000</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">jdbc</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">驱动程序。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">在微软站点就有这个驱动程序：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>Window</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">操作系统</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>http://www.uncj.com/upload/files/ms_jdbc_setup.exe <BR><BR>http://download.microsoft.com/download/3/0/f/30ff65d3-a84b-4b8a-a570-27366b2271d8/setup.exe<BR><BR><BR><BR>Unix</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">操作系统</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"> Mssqlserver.tar <BR><BR>http://download.microsoft.com/download/3/0/f/30ff65d3-a84b-4b8a-a570-27366b2271d8/mssqlserver.tar<BR><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">二、安装</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">JDBC<BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">执行</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">ms_jdbc_setup.exe</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">可执行文件，一切只需要点击下一步，至到出现</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">finish</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">按钮，完成安装。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">注：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>(1) ms_JDBC_setup</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">默认安装路径为：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC<BR><BR>(2)</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">此版</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">(Version 2.2.0022)</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">本仅支持</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">Microsoft SQL Server 2000 Driver for JDBC <BR><BR>(3)</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">安装目录</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">\lib\</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">下的三个</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">jar</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">文件即是我们要的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">JDBC</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">驱动核心</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>msbase.jar<BR><BR>mssqlserver.jar<BR><BR>msutil.jar<BR><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">三、将以上（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">3</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">）中指的三个</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">jar</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">文件加入到环境变量中去</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>classpath</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>d:\webserver\lib\msbase.jar;d:\webserver\lib\mssqlserver.jar;d:\webserver\lib\msutil.jar<BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">注：也可以省事的将以上三个文件拷贝至你的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">jvm</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">机所在的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">JAVA_HOME\jre\lib\ext</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">目录下，不过不建议这么做。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">四、测试</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>jsp</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">文件：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>&lt;%@ page contentType="text/html;charset=gb2312"%&gt; <BR><BR>&lt;%@ page import="java.sql.*"%&gt; <BR><BR>&lt;html&gt; <BR><BR>&lt;body&gt; <BR><BR>&lt;%<BR><BR>Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); <BR><BR>String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=haiguan"; <BR><BR>String user="sa"; <BR><BR>String password=""; <BR><BR>Connection conn= DriverManager.getConnection(url,user,password); <BR><BR>Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); <BR><BR>String sql="select * from xt_user"; <BR><BR>ResultSet rs=stmt.executeQuery(sql); <BR><BR>while(rs.next()) <BR><BR>{<BR><BR>%&gt; <BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">您的第一个字段内容为：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">&lt;%=rs.getString(1)%&gt; <BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">您的第二个字段内容为：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">&lt;%=rs.getString(2)%&gt; <BR><BR>&lt;%<BR><BR>}<BR><BR>%&gt; <BR><BR>&lt;%out.print("</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">数据库操作成功，恭喜你</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">");%&gt; <BR><BR>&lt;%<BR><BR>rs.close(); <BR><BR>stmt.close(); <BR><BR>conn.close(); <BR><BR>%&gt; <BR><BR>&lt;/body&gt; <BR><BR>&lt;/html&gt;<BR><BR><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">五、注意事项</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>1. </SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">要保证你的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">Sql</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">服务是启动状态</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>2. </SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">在</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">Sql </SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">的管理器中能够使用</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">sa</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">或其它用户正常登录；</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">(</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">有些人在安装</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">sql</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">时用了</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">nt</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">用户管理模式，这里可能会有一定问题</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">)<BR><BR>3. </SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">第一次配置好环境变量最好能重启一下电脑</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>4. </SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">注意</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">JVM</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">和</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">DataBase</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">的启动顺序：先启动</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">DataBase</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">，再启动</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">JVM</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">机。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">注：在停止</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">Web</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">服务器后，再重启动，中间最好能有</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">10</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">秒以上的间隔。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>5. </SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">注意操作系统的网络连通性</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>A.</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">启动了</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">Tcp/IP</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">服务</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><BR><BR>B.</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">配置了相关</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">IP</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">地址</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">,</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">有些人机器可能用的是自动分配</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">IP</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">或有配置</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">IP</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">时，但网络不通可能也找不到</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">IP<BR><BR>6. </SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">有些机器在调试明最好能将（四）中的连接地址</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">localhost</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">改成数据库服务器的</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">IP,</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">这也是要注意</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt">5</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-font-kerning: 0pt; mso-bidi-font-family: Tahoma">的原因。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Tahoma; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P><img src ="http://www.cnitblog.com/tab1002/aggbug/6207.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/tab1002/" target="_blank">咚咚咚</a> 2006-01-17 10:34 <a href="http://www.cnitblog.com/tab1002/articles/6207.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tomcat无法启动的问题</title><link>http://www.cnitblog.com/tab1002/articles/6140.html</link><dc:creator>咚咚咚</dc:creator><author>咚咚咚</author><pubDate>Thu, 12 Jan 2006 03:56:00 GMT</pubDate><guid>http://www.cnitblog.com/tab1002/articles/6140.html</guid><wfw:comment>http://www.cnitblog.com/tab1002/comments/6140.html</wfw:comment><comments>http://www.cnitblog.com/tab1002/articles/6140.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cnitblog.com/tab1002/comments/commentRss/6140.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/tab1002/services/trackbacks/6140.html</trackback:ping><description><![CDATA[<P>1.<STRONG>TOMCAT启动时有一些显示,但仍会自动关闭,无法启动.</STRONG></P>
<P>问题解答：<BR>　&nbsp;&nbsp; 可能是地址被占用,运行桌面上的"关闭TOMCAT"快捷方式,执行完毕后再启动TOMCAT.</P>
<P>2.<STRONG>TOMCAT启动时一闪而过,无法启动.</STRONG></P>
<P>问题解答：<BR>　　可能是端口被占用,可找到TOMCAT的安装目录下的SERVER.XML文件,如..\EAM2003\conf\SERVER.XML,用记事本打开此文件,查找8080,如果找到,就将8080改为8088.</P>
<P><STRONG>3.TOMCAT能正常启动,可见到登录界面,但登录不进系统</STRONG></P>
<P>问题解答：<BR>　　 可能是IE的设置问题,将所有设置回复成默认设置,关闭"上网助手"或其他IE插件的"拦截弹出窗口"的功能.</P><img src ="http://www.cnitblog.com/tab1002/aggbug/6140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/tab1002/" target="_blank">咚咚咚</a> 2006-01-12 11:56 <a href="http://www.cnitblog.com/tab1002/articles/6140.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用Junit测试void方法</title><link>http://www.cnitblog.com/tab1002/articles/5875.html</link><dc:creator>咚咚咚</dc:creator><author>咚咚咚</author><pubDate>Thu, 29 Dec 2005 02:14:00 GMT</pubDate><guid>http://www.cnitblog.com/tab1002/articles/5875.html</guid><wfw:comment>http://www.cnitblog.com/tab1002/comments/5875.html</wfw:comment><comments>http://www.cnitblog.com/tab1002/articles/5875.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cnitblog.com/tab1002/comments/commentRss/5875.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/tab1002/services/trackbacks/5875.html</trackback:ping><description><![CDATA[<SPAN style="FONT-SIZE: 12px">Junit通常用于那些有明确返回值的方法的测试，而无法对返回值是void类型的方法进行测试，因为Junit的assert断言方法只适用于预期值与实际值的比较，对于void类型的方法，我们无法从它的return语句获得具体的返回值。因此我们要使用junit测试void方法，必须找到一个有实际返回值的方法来暂时替代void方法，但此方法只作为被测void方法的入口和出口，测试程序所调用的仍旧是原void方法。为了实现这种测试方式，我们按照如下步骤进行。<BR>第一步：增加全局变量flag。<BR>public static int flag=0;<BR>在被测程序中增加一个int类型的全局变量flag，这个flag最终也会随代码进入生产系统，但这并不影响生产运行。增加这个flag的作用是，用来给void方法的每个分支的结果进行赋值，我们可以给不同的分支附不同的flag值，这样，在用junit测试时，当我们给定一个输入，我们就能知道它会走哪条分支，此时的flag应该是什么值。<BR>第二步：增加与void方法对应的verify方法，该方法返回int型的flag。<BR>&nbsp; &nbsp; &nbsp; &nbsp; public static int verInsertData(String id, String name, String sex)<BR>&nbsp; &nbsp; &nbsp; &nbsp; {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyCode mycode = new MyCode();<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyCode.insertData(id, name, sex);<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(e.toString());<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return flag;<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR><BR>从上面的程序可以看出，被测方法inserData被增加的verify方法verInsertData所调用，且返回值是一个int型的flag。<BR>第三步：为被测方法设定每个分支的返回值。<BR>&nbsp; &nbsp; &nbsp; &nbsp; static void insertData(String person_id, String person_name, String person_sex)<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throws Exception {<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //personid必须为正整数<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (person_id.equals("")||estimate(person_id)== 0) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(<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; "personid must be digital and bigger than 0!");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag=1;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; //if (person_id == "1")<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Integer.parseInt(person_id) == 1) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(<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; "Duplicate personid,this person has been existed! ");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag=2;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; //Test whether personname is blank<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (person_name.equals("")) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(<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; "personname must be input!");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag=3;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &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; &nbsp; &nbsp; &nbsp; &nbsp; //Test whether personsex is 'm' or 'f'<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!person_sex.equals("m") &amp;&amp; !person_sex.equals("f")) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println("Invalide input ,personsex must be 'm' or 'f'!");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag=4;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<BR><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; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "' " + person_name + " ' has been added successfully");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag=0;<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(e.getMessage().toString());<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } finally {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR>被测方法被分成了五个分支，每个分支对都flag标志位附了不同的值，分别是0，1，2，3，4。这样的布局显然就为后面的Junit测试代码创造了良好的条件。Junit代码在已知的输入数据下，能够很快得到预期的flag值，assert时，只需要将输入数据、预期值分别提供给asserEqual方法，Juint测试代码执行时就会自动将预期的flag与实际被测程序执行的结果进行比对，如果实际得到的flag与预期的一致，说明被测程序是正确的，反之则是错误的。<BR>第四步：编写Junit测试代码。<BR>package com;<BR>import junit.framework.TestCase;<BR><BR>public class TestMyCode extends TestCase {<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; public MyCode mycode = new MyCode();<BR>&nbsp; &nbsp; &nbsp; &nbsp; protected void setUp() throws Exception {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super.setUp();<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mycode = new MyCode();<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; public void testInsertData1() {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int expectedReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int actualReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn = 0; //insert成功，即预期的flag＝0<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn = MyCode.verInsertData("2", "111", "m");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertEquals(<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "UTC-MyCode-insertData-01--正确等价类：sucess",<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn);<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(e.toString());<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; public void testInsertData2() {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int expectedReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int actualReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn = 1; //id为空，insert失败，，即预期的flag＝1<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn = MyCode.verInsertData("", "111", "m");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertEquals(<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "UTC-MyCode-insertData-02--错误等价类：fail:1",<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn);<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(e.toString());<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; public void testInsertData3() {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int expectedReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int actualReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn = 2; //id为1，重复，insert失败，即预期的flag＝2<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn = MyCode.verInsertData("1", "222", "f");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertEquals(<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "UTC-MyCode-insertData-03--错误等价类：fail:2",<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn);<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(e.toString());<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; public void testInsertData4() {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int expectedReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int actualReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn = 3; //name为空，insert失败，即预期的flag＝3<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn = MyCode.verInsertData("3", "", "f");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertEquals(<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "UTC-MyCode-insertData-04--错误等价类：fail:3",<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn);<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(e.toString());<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; public void testInsertData5() {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int expectedReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int actualReturn;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn = 4; //sex不是m或f，insert失败，即预期的flag＝4<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn = MyCode.verInsertData("4", "ggg", "h");<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; assertEquals(<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "UTC-MyCode-insertData-05--错误等价类：fail:4",<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expectedReturn,<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actualReturn);<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println(e.toString());<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; protected void tearDown() throws Exception {<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mycode = null;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super.tearDown();<BR>&nbsp; &nbsp; &nbsp; &nbsp; }<BR>}</SPAN> <BR><img src ="http://www.cnitblog.com/tab1002/aggbug/5875.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/tab1002/" target="_blank">咚咚咚</a> 2005-12-29 10:14 <a href="http://www.cnitblog.com/tab1002/articles/5875.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>利用eclipse构架项目</title><link>http://www.cnitblog.com/tab1002/articles/5874.html</link><dc:creator>咚咚咚</dc:creator><author>咚咚咚</author><pubDate>Thu, 29 Dec 2005 02:02:00 GMT</pubDate><guid>http://www.cnitblog.com/tab1002/articles/5874.html</guid><wfw:comment>http://www.cnitblog.com/tab1002/comments/5874.html</wfw:comment><comments>http://www.cnitblog.com/tab1002/articles/5874.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/tab1002/comments/commentRss/5874.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/tab1002/services/trackbacks/5874.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 创建测试工程：启动eclipse，使新安装的插件生效，开始正式创建工程。 1、使用Sysdeo Tomcat Plugin创建tomcat工程： File-&gt;new-&gt;others，打开新建向导对话框，在树中找到java-&gt;tomcat projects，选中，点击next按钮。在projects name中输入textweb，选中Use default，点击next。在下一...&nbsp;&nbsp;<a href='http://www.cnitblog.com/tab1002/articles/5874.html'>阅读全文</a><img src ="http://www.cnitblog.com/tab1002/aggbug/5874.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/tab1002/" target="_blank">咚咚咚</a> 2005-12-29 10:02 <a href="http://www.cnitblog.com/tab1002/articles/5874.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse快速上手指南之使用JUnit(出处: J2ME开发网)</title><link>http://www.cnitblog.com/tab1002/articles/5873.html</link><dc:creator>咚咚咚</dc:creator><author>咚咚咚</author><pubDate>Thu, 29 Dec 2005 01:53:00 GMT</pubDate><guid>http://www.cnitblog.com/tab1002/articles/5873.html</guid><wfw:comment>http://www.cnitblog.com/tab1002/comments/5873.html</wfw:comment><comments>http://www.cnitblog.com/tab1002/articles/5873.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/tab1002/comments/commentRss/5873.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/tab1002/services/trackbacks/5873.html</trackback:ping><description><![CDATA[<SPAN class=f14><STRONG>在Eclipse中使用JUnit<BR><BR></STRONG>　　测试对于保证软件开发质量有着非常重要的作用，单元测试更是必不可少，JUnit是一个非常强大的单元测试包，可以对一个/多个类的单个/多个方法测试，还可以将不同的TestCase组合成TestSuit，使测试任务自动化。Eclipse同样集成了JUnit，可以非常方便地编写TestCase。<BR><BR>　　我们创建一个Java工程，添加一个example.Hello类，首先我们给Hello类添加一个abs()方法，作用是返回绝对值：<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG onerror="this.src='http://www.yesky.com/image20010518/207852.jpg';" hspace=3 src="file:///E:/study/eclipse/Eclipse下的Junit/Eclipse快速上手指南之使用JUnit.files/207852.jpg" align=center vspace=1 border=1></DIV></TD></TR></TBODY></TABLE><BR><BR>　　下一步，我们准备对这个方法进行测试，确保功能正常。选中Hello.java，右键点击，选择New-&gt;JUnit Test Case：<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG onerror="this.src='http://www.yesky.com/image20010518/207853.jpg';" hspace=3 src="file:///E:/study/eclipse/Eclipse下的Junit/Eclipse快速上手指南之使用JUnit.files/207853.jpg" align=center vspace=1 border=1></DIV></TD></TR></TBODY></TABLE><BR>　　 Eclipse会询问是否添加junit.jar包，确定后新建一个HelloTest类，用来测试Hello类。<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG onerror="this.src='http://www.yesky.com/image20010518/207854.jpg';" hspace=3 src="file:///E:/study/eclipse/Eclipse下的Junit/Eclipse快速上手指南之使用JUnit.files/207854.jpg" align=center vspace=1 border=1></DIV></TD></TR></TBODY></TABLE><BR>　　选中setUp()和tearDown()，然后点击“Next”：<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG onerror="this.src='http://www.yesky.com/image20010518/207855.jpg';" hspace=3 src="file:///E:/study/eclipse/Eclipse下的Junit/Eclipse快速上手指南之使用JUnit.files/207855.jpg" align=center vspace=1 border=1></DIV></TD></TR></TBODY></TABLE>　　<BR>　　选择要测试的方法，我们选中abs(int)方法，完成后在HelloTest.java中输入：<BR><BR>　　　　<IMG onerror="this.src='http://www.yesky.com/image20010518/207856.jpg';" hspace=3 src="file:///E:/study/eclipse/Eclipse下的Junit/Eclipse快速上手指南之使用JUnit.files/207856.jpg" align=center vspace=1 border=1><BR><BR>　　 JUnit会以以下顺序执行测试：（<FONT color=#ff0000>大致的代码</FONT>） 
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#b3b3b3 border=1>
<TBODY>
<TR>
<TD><FONT face="Courier New" color=#006400>try {<BR>HelloTest test = new HelloTest(); // 建立测试类实例<BR>test.setUp(); // 初始化测试环境<BR>test.<STRONG><FONT color=#000080>testAbs</FONT></STRONG>(); // 测试某个方法<BR>test.tearDown(); // 清理资源<BR>}<BR>catch…</FONT><BR></TD></TR></TBODY></TABLE><BR>　　setUp()是建立测试环境，这里创建一个Hello类的实例；tearDown()用于清理资源，如释放打开的文件等等。以test开头的方法被认为是测试方法，JUnit会依次执行testXxx()方法。在testAbs()方法中，我们对abs()的测试分别选择正数，负数和0，如果方法返回值与期待结果相同，则assertEquals不会产生异常。<BR><BR>　　如果有多个testXxx方法，JUnit会创建多个XxxTest实例，每次运行一个testXxx方法，setUp()和tearDown()会在testXxx前后被调用，因此，不要在一个testA()中依赖testB()。<BR><BR>　　直接运行Run-&gt;Run As-&gt;JUnit Test，就可以看到JUnit测试结果：<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG onerror="this.src='http://www.yesky.com/image20010518/207857.jpg';" hspace=3 src="file:///E:/study/eclipse/Eclipse下的Junit/Eclipse快速上手指南之使用JUnit.files/207857.jpg" align=center vspace=1 border=1></DIV></TD></TR></TBODY></TABLE><BR>　　绿色表示测试通过，只要有1个测试未通过，就会显示红色并列出未通过测试的方法。可以试图改变abs()的代码，故意返回错误的结果（比如return n+1;），然后再运行JUnit就会报告错误。<BR><BR>　　如果没有JUnit面板，选择Window-&gt;Show View-&gt;Other，打开JUnit的View：<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG onerror="this.src='http://www.yesky.com/image20010518/207858.jpg';" hspace=3 src="file:///E:/study/eclipse/Eclipse下的Junit/Eclipse快速上手指南之使用JUnit.files/207858.jpg" align=center vspace=1 border=1></DIV></TD></TR></TBODY></TABLE><BR>　　JUnit通过单元测试，能在开发阶段就找出许多Bug，并且，多个Test Case可以组合成Test Suite，让整个测试自动完成，尤其适合于XP方法。每增加一个小的新功能或者对代码进行了小的修改，就立刻运行一遍Test Suite，确保新增和修改的代码不会破坏原有的功能，大大增强软件的可维护性，避免代码逐渐“腐烂”.</SPAN><img src ="http://www.cnitblog.com/tab1002/aggbug/5873.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/tab1002/" target="_blank">咚咚咚</a> 2005-12-29 09:53 <a href="http://www.cnitblog.com/tab1002/articles/5873.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse 3.0 上配置JSP开发环境(出处：CSDN)</title><link>http://www.cnitblog.com/tab1002/articles/5872.html</link><dc:creator>咚咚咚</dc:creator><author>咚咚咚</author><pubDate>Thu, 29 Dec 2005 01:48:00 GMT</pubDate><guid>http://www.cnitblog.com/tab1002/articles/5872.html</guid><wfw:comment>http://www.cnitblog.com/tab1002/comments/5872.html</wfw:comment><comments>http://www.cnitblog.com/tab1002/articles/5872.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/tab1002/comments/commentRss/5872.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/tab1002/services/trackbacks/5872.html</trackback:ping><description><![CDATA[首先讲一下环境配置，注意我配置的环境是在win 2000 server下的，不是linux下的，配置的大致流程和操作系统无关，仅仅是在具体的安装上有差别。而配置成功与否，与操作系统无关。 
<P>　　软件安装分为一下几个部分：<BR>1、 java环境安装：</P>
<P>　　这里使用的是jdk1.4.1（jdk1.4.2也可以），这个可以到sun公司的网站去下载； </P>
<P>　　2、 tomcat环境安装：</P>
<P>　　tomcat的版本是4.1的，安装版或是解压版都是可以的；</P>
<P>　　3、 eclipse 3 安装：</P>
<P>　　可以去下列地址下载<A href="http://www.eclipse.org/downloads/index.php"><FONT color=#000000>http://www.eclipse.org/downloads/index.php</FONT></A></P>
<P>　　我下载的是 3.1M4 版本，这个版本应该是比较新的。 4、 tomcat插件安装；</P>
<P>　　tomcat插件是要到下面地址下载<A href="http://www.sysdeo.com/eclipse/tomcatPlugin.html"><FONT color=#000000>http://www.sysdeo.com/eclipse/tomcatPlugin.html</FONT></A>，下载之前需要查看插件是否适合eclipse的版本，我下载的是tomcatPluginV3.zip；</P>
<P>　　5、 lomboz插件安装；</P>
<P>　　lomboz插件需要下载两个部分，一个是emf环境，另一个是lomboz插件，分别到下列地方去找</P>
<P><A href="http://forge.objectweb.org/project/showfiles.php?group_id=97"><FONT color=#000000>http://forge.objectweb.org/project/showfiles.php?group_id=97</FONT></A></P>
<P><A href="http://download.eclipse.org/tools/emf/scripts/downloads.php#goto2.1.0I"><FONT color=#000000>http://download.eclipse.org/tools/emf/scripts/downloads.php#goto2.1.0I</FONT></A></P>
<P>　　我下载的是emf-sdo-runtime-I200412160800.zip和org.objectweb.lomboz_3.1.0.N20050106.zip ；</P>
<P>　　这里主要是根据eclipse选择适当的lomboz插件，然后查看一下lomboz插件的 介绍，那里会介绍需要的emf插件的版本，然后再去下面的地址找emf插件。</P>
<P>　　好了，该下载的都有了，下面我介绍一下如何安装和配置。</P>
<P>　　一、 java环境安装</P>
<P>　　这个只要直接安装就可以了，不过最好能安装在系统盘以外的地方，这样可以更好理解jvm的配置；安装好了以后，需要配置环境变量，新建JAVA_HOME，并且配置path，把jdk的bin目录添加进去，这样就可以在命令行的任何路径使用jdk的命令了。</P>
<P>　　[测试] ：编写一个hello world程序，然后在dos下使用javac hello.java和java hello命令，如果可以正常执行，就证明jdk安装成功了。</P>
<P>　　二、 tomcat安装</P>
<P>　　解压版的直接解压就可以了，然后配置TOMCAT_HOME，安装版的要注意的两点，一个是安装完之后tomcat的服务就能够启动的了，但是还是要配置TOMCAT_HOME；第二个就是需要查看一下安装程序是不是把tomcat服务注册成为windows的启动服务，需要到“服务”里查看，如果有这个选项就把它设置为手动启动，并且先停止这个服务。</P>
<P>　　[测试]：使用startup.bat命令，服务正常启动之后，ie浏览器里输入</P>
<P>　　<A href="http://localhost:8080/"><FONT color=#000000>http://localhost:8080/</FONT></A> 如果出现正常的小猫页面，那就应该没有问题了。 </P>
<P>　　三、 eclipse 3安装</P>
<P>　　eclipse的安装倒是很简单，只要解压，然后把eclipse目录复制到盘符下就可以了，启动的时候，系统会自动寻找jvm，当然可以再以后配置，但是好像是必须先安装jdk。</P>
<P>　　四、 tomcat插件安装，emf插件安装，lomboz插件安装</P>
<P>　　这几部分的步骤都是一样的，解压软件包，然后根据里面的目录结构，把目录文件分别复制到feature或plugins目录里，这样就行了，下面将详细讲述一下eclipse的配置。</P>
<P>　　五、 配置eclipse</P>
<P>　　1、 首先，打开配置界面 window-&gt;preferences。如果这几个插件安装成功，左边的列表里应该有lomboz和tomcat的选项。如果没有，检查上面的步骤是不是正确。</P>
<P>　　点击java-&gt;Installed JREs，然后显示如上，如果是初始安装的，只有显示第一个jre（不要问我什么是jre，自己查资料去），那是系统默认的安装在c盘的jre，如果系统当中安装了多个jdk，那么最好还是新建一个，点击add，然后选择你需要使用的jdk的位置，然后它会自动寻找其他的参数，点击ok。返回界面之后，不要忘记点选刚刚添加的jdk，要不然是没有用的。然后点击ok关闭这个窗口。</P>
<P>　　2、 再次打开配置界面，点击tomcat选项</P>
<P>　　这里是配置tomcat的参数，根据你安装的tomcat的版本，选择tomcat version，然户找到该tomcat的主目录，输入在tomcat home，下面的参数会自动配置，点击apply。 然后在左边选择advanced，同样把tomcat的主目录复制在tomcat base，点击apply。</P>
<P>　　最后在左边选择jvm setting，选择刚刚加入的jre，点击apply，点击ok。这样就可以了。回到界面，点击工具栏上的黄色小猫的图标，如果配置正确，在console里应该有启动tomcat的信息。如果有，就代表tomcat配置成功了。</P>
<P>　　lomboz基本上不用什么配置，如果左边有那个lomboz选项，基本上就是成功了。点击lomboz，然后选择刚才配置的jdk里的tools.jar，这样配置就完成了。测试的方法是新建一个jsp文件，看看打开的时候是不是对script代码有特殊显示，并且建个测试类，看看jsp是不是能够自动引用类里的函数.</P><img src ="http://www.cnitblog.com/tab1002/aggbug/5872.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/tab1002/" target="_blank">咚咚咚</a> 2005-12-29 09:48 <a href="http://www.cnitblog.com/tab1002/articles/5872.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>