
2005年6月23日
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
</head>
<body>
?<SCRIPT language="javascript">
?function next()
?? {
?? if(event.keyCode==13)event.keyCode=9;
? }
?</SCRIPT>
<form name="form1" method="post" action="">
<input onkeydown="next()" name="text1">
<input onkeydown="next()" name="text2">
<input onkeydown="next()" name="text3">
<input onkeydown="next()" name="text5">
<input onkeydown="if(event.keyCode==13)event.keyCode=9" name="text4">
? <input type="submit" name="Submit" value="Submit">
? <input type="reset" name="Submit2" value="Reset">
</form>
</body>
</html>
posted @
2006-04-04 13:24 似水流年 閱讀(3300) |
評論 (1) |
編輯 收藏
摘要: 以下是摘自http://xdoclet.sourceforge.net/xdoclet/tags/hibernate-tags.html的內容
@hibernate Tag Reference
Tags for declaration of Hibernate descriptor file
Applies to: All classes, at class level and on get...
閱讀全文
posted @
2005-11-15 14:03 似水流年 閱讀(1126) |
評論 (0) |
編輯 收藏
一.安裝
1.安裝jdk1.5,E:\server\jdk1.5
2.安裝mysql 4.0,E:\server\mysql
3.安裝Ant 1.6,E:\apache-ant-1.6.2
4.安裝tomcat5.5,E:\tomcat5
二.系統路徑的設置:
1、JAVA_HOME = E:\server\jdk1.5
2、MYSQL_HOME = E:\server\mysql
3、ANT_HOME = E:\apache-ant-1.6.2
4、CATALINA_HOME = E:\tomcat5
5、path,%JAVA_HOME%\bin;%ANT_HOME%\bin;%CATALINA_HOME%\bin;%MYSQL_HOME%\bin
三.安裝appfuse-1.8.2,E:\jbproject\appfuse
1.將..\appfuse\lib\junit3.8.1\junit.jar拷貝到%ANT_HOME%/lib目錄下
2.根據需要修改build.properties以下部分
#database.jar=${postgresql.jar}
#database.type=postgresql
#database.host=localhost
#database URL for creating other databases (doesn't work with pgsql)
#database.admin.url=jdbc:${database.type}://${database.host}/template1
#database.admin.username=postgres
#database.admin.password=postgres
#hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#database.driver_class=org.postgresql.Driver
#database.url=jdbc:${database.type}://${database.host}/${database.name}
我只修改了database.admin.password=我的mysql密碼
3.安裝的可選項,
如果你希望使用 iBATIS 作為持久化framework, 查看extras/ibatis目錄下的 README.txt 文件或者運行 ant install-ibatis。
如果你希望使用 Spring 作為web framework, 查看 extras/spring 目錄下的 README.txt 文件或者運行 ant install-springmvc。
如果你希望使用 WebWork 作為web framework, 查看extras/webwork 目錄下的 README.txt 文件或者運行 ant install-webwork。
如果你希望使用 JSF 作為web framework, 查看 extras/jsf 目錄下的 README.txt 文件或者運行 ant install-jsf。
如果你希望使用 Tapestry 作為web framework, 查看 extras/tapestry 目錄下的 README.txt 文件或者運行 ant install-tapestry。
四.新建項目
1. 在控制臺,E:\jbproject\appfuse>ant new 按照提示輸入application名稱(myapp),database名稱(mydb),package名稱(com.jinn).
2. 如果package名稱不是org.appfuse,拷貝appfuse下的ApplicationResources_zh_CN.properties和ApplicationResources_zh.properties到對應的路徑下myapp下。(注意如果你的package名稱不是org.appfuse(或不是以org開頭?沒有做過測試),會提示你輸入the first part of your new package,先別忙著
輸入,看看myapp,跟appfuse一樣,我要你著重看看myapp\web\WEB-INF\classes下的ApplicationResources_zh_CN.properties或ApplicationResources_zh.properties
跟appfuse下是一樣的。輸入the first part of your new package,例如com,再看看myapp\web\WEB-INF\classes下的ApplicationResources_zh_CN.properties或ApplicationResources_zh.properties
它的內容變了。原來appfuse在執行rename package的過程中把相關的properties內容做了處理。這會造成頁面顯示亂碼。
3. 運行E:\jbproject\myapp>ant setup ,BUILD SUCCESSFUL,在瀏覽器輸入http://localhost:8080/myapp。一切正常,此時打開查看${CATALINA_HOME}\webapps\myapp\WEB-INF\classes\ApplicationResources_zh_CN.properties,已被編碼轉換。
4. 關閉tomcat,運行E:\jbproject\myapp>ant test-all,出錯," failed with message "Wrong document title found! Expected "AppFuse
~ ???è?????" but got "AppFuse ~ ???è?????",顯然還是資源文件編碼的問題,注意控制臺有段提示"test with locale 'zh'",將myapp\web\WEB-INF\classes>ApplicationResources_zh.properties更名為ApplicationResources_zh.properties.bak
運行E:\jbproject\myapp\web\WEB-INF\classes>native2ascii -encoding gbk ApplicationResources_zh.properties ApplicationResources_zh.properties
再次運行E:\jbproject\myapp>ant test-all BUILD SUCCESSFUL
參考文章:http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseQuickStart_zh
posted @
2005-11-15 11:20 似水流年 閱讀(636) |
評論 (0) |
編輯 收藏
AppFuse的Ant任務
This page contains a listing of the most common Ant targets in AppFuse that I use in my daily development. For a complete list of tasks, type "ant -projecthelp" at the command line.
任務 |
描述 |
setup |
建立database, 配置tomcat和deploys expanded war |
clean |
Removes build artifacts |
compile |
編譯所有的文件 |
deploy |
編譯、然后部署到Tomcat |
deploy-web |
部署JSP和靜態Web內容到Tomcat |
install |
使用Tomcat的Manager程序安裝Web程序. 對于向遠程服務器上部署程序很適合 |
list |
列出Tomcat已經安裝、部署好的應用 |
refresh |
Undeploys, cleans, 然后重新部署. |
reload |
使Tomcat重新裝載所有程序 |
remove |
刪除Tomcat部署好的程序 |
setup-db |
創建數據庫,并插入范例需要的數據 |
setup-tomcat |
復制JDBC驅動和context.xml到Tomcat相應目錄下 |
test-all |
運行所有用于測試dao, service和web的測試用例 |
test-dao |
測試dao模塊 |
test-service |
測試service模塊 |
test-web |
使用Mocks測試Action/Controller (不需要容器) |
test-jsp |
在Tomcat中運行Canoo WebTest (啟動/停止Tomcat, 執行前Tomcat應該被停止) |
test-canoo |
當Tomcat已經運行時,執行Canoo WebTest |
test-reports |
產生測試報告 |
undeploy |
從 $CATALINA_HOME/webapps中刪除war文件和相應的目錄 |
posted @
2005-11-11 14:14 似水流年 閱讀(426) |
評論 (0) |
編輯 收藏
三個需要的程序包:
commons-dbcp-1.2.1.jar
http://apache.linuxforum.net/dist/jakarta/commons/dbcp/binaries/
struts-legacy.jar
http://apache.linuxforum.net/dist/jakarta/struts/struts-legacy/
commons-pool-1.2.jar
http://apache.linuxforum.net/dist/jakarta/commons/pool/binaries/
strut-config.xml
<data-sources>
<data-source key="mysqlWebDB" type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="description" value="Mysql DataSource For zyweb" />
<set-property property="driverClassName" value="org.gjt.mm.mysql.Driver" />
<set-property property="url" value="jdbc:mysql://localhost:3306/zyweb?useUnicode=true&characterEncoding=GBK" />
<set-property property="username" value="root" />
<set-property property="password" value="zyadmin" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000"/>
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false"/>
</data-source>
</data-sources>
posted @
2005-10-13 16:24 似水流年 閱讀(656) |
評論 (0) |
編輯 收藏
Java 中對文件的讀寫操作之比較
一.在 JDK 1.0 中,通常是用 InputStream & OutputStream 這兩個基類來進行讀寫操作的。
InputStream 中的 FileInputStream 類似一個文件句柄,通過它來對文件進行操作,類似的,在
OutputStream 中我們有 FileOutputStream 這個對象。
用FileInputStream 來讀取數據的常用方法是:
FileInputStream fstream = new FileInputStream(args[0]);
DataInputStream in = new DataInputStream(fstream);
用 in.readLine() 來得到數據,然后用 in.close() 關閉輸入流。
完整代碼見 Example 1。
用FileOutputStream 來寫入數據的常用方法是:
FileOutputStream out out = new FileOutputStream("myfile.txt");
PrintStream p = new PrintStream( out );
用 p.println() 來寫入數據,然后用 p.close() 關閉輸入。
完整代碼見 Example 2。
二.在 JDK 1.1中,支持兩個新的對象 Reader & Writer, 它們只能用來對文本文件進行操作,而
JDK1.1中的 InputStream & OutputStream 可以對文本文件或二進制文件進行操作。
用FileReader 來讀取文件的常用方法是:
FileReader fr = new FileReader("mydata.txt");
BufferedReader br = new BufferedReader(fr);
用 br.readLing() 來讀出數據,然后用br.close() 關閉緩存,用fr.close() 關閉文件。
完整代碼見 Example 3。
用 FileWriter 來寫入文件的常用方法是:
FileWriter fw = new FileWriter("mydata.txt");
PrintWriter out = new PrintWriter(fw);
在用out.print 或 out.println 來往文件中寫入數據,out.print 和 out.println的唯一區別是后者寫
入數據或會自動開一新行。寫完后要記得 用out.close() 關閉輸出,用fw.close() 關閉文件。
完整代碼見 Example 4。
-------------------------------------------------------------- following is the source code of examples------------------------------------------------------
Example 1:
// FileInputDemo
// Demonstrates FileInputStream and DataInputStream
import java.io.*;


class FileInputDemo
{

public static void main(String args[])
{
// args.length is equivalent to argc in C

if (args.length == 1)
{

try
{
// Open the file that is the first command line parameter
FileInputStream fstream = new FileInputStream(args[0]);
// Convert our input stream to a DataInputStream
DataInputStream in = new DataInputStream(fstream);
// Continue to read lines while there are still some left to read

while (in.available() !=0)
{
// Print file line to screen
System.out.println (in.readLine());
}
in.close();

} catch (Exception e)
{
System.err.println("File input error");
}
}
else
System.out.println("Invalid parameters");
}
}

Example 2:
// FileOutputDemo
// Demonstration of FileOutputStream and PrintStream classes
import java.io.*;

class FileOutputDemo


{

public static void main(String args[])
{
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object


try
{
// connected to "myfile.txt"
out = new FileOutputStream("myfile.txt");
// Connect print stream to the output stream
p = new PrintStream( out );
p.println ("This is written to a file");
p.close();

} catch (Exception e)
{
System.err.println ("Error writing to file");
}
}
}

Example 3:
// FileReadTest.java
// User FileReader in JDK1.1 to read a file
import java.io.*;


class FileReadTest
{

public static void main (String[] args)
{
FileReadTest t = new FileReadTest();
t.readMyFile();
}

void readMyFile()
{
String record = null;
int recCount = 0;

try
{
FileReader fr = new FileReader("mydata.txt");
BufferedReader br = new BufferedReader(fr);
record = new String();

while ((record = br.readLine()) != null)
{
recCount++;
System.out.println(recCount + ": " + record);
}
br.close();
fr.close();

} catch (IOException e)
{
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
}
}

Example 4:
// FileWriteTest.java
// User FileWriter in JDK1.1 to writer a file
import java.io.*;


class FileWriteTest
{

public static void main (String[] args)
{
FileWriteTest t = new FileWriteTest();
t.WriteMyFile();
}

void WriteMyFile()
{

try
{
FileWriter fw = new FileWriter("mydata.txt");
PrintWriter out = new PrintWriter(fw);
out.print(“hi,this will be wirte into the file!”);
out.close();
fw.close();

} catch (IOException e)
{
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
}
}

posted @
2005-06-23 17:46 似水流年 閱讀(902) |
評論 (2) |
編輯 收藏