隨筆-26  評論-13  文章-46  trackbacks-0
            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 似水流年 閱讀(3304) | 評論 (1)編輯 收藏
               摘要: 以下是摘自http://xdoclet.sourceforge.net/xdoclet/tags/hibernate-tags.html的內(nèi)容 @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 似水流年 閱讀(1129) | 評論 (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

          二.系統(tǒng)路徑的設(shè)置:

             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.根據(jù)需要修改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到對應(yīng)的路徑下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
                它的內(nèi)容變了。原來appfuse在執(zhí)行rename package的過程中把相關(guān)的properties內(nèi)容做了處理。這會造成頁面顯示亂碼。
             3. 運行E:\jbproject\myapp>ant setup ,BUILD SUCCESSFUL,在瀏覽器輸入http://localhost:8080/myapp。一切正常,此時打開查看${CATALINA_HOME}\webapps\myapp\WEB-INF\classes\ApplicationResources_zh_CN.properties,已被編碼轉(zhuǎn)換。
             4. 關(guān)閉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 似水流年 閱讀(638) | 評論 (0)編輯 收藏
           

          AppFuseAnt任務(wù)

          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.
          任務(wù)
          描述

          setup

          建立database, 配置tomcatdeploys expanded war

          clean

          Removes build artifacts

          compile

          編譯所有的文件

          deploy

          編譯、然后部署到Tomcat

          deploy-web

          部署JSP和靜態(tài)Web內(nèi)容到Tomcat

          install

          使用TomcatManager程序安裝Web程序.
          對于向遠程服務(wù)器上部署程序很適合

          list

          列出Tomcat已經(jīng)安裝、部署好的應(yīng)用

          refresh

          Undeploys, cleans, 然后重新部署.

          reload

          使Tomcat重新裝載所有程序

          remove

          刪除Tomcat部署好的程序

          setup-db

          創(chuàng)建數(shù)據(jù)庫,并插入范例需要的數(shù)據(jù)

          setup-tomcat

          復(fù)制JDBC驅(qū)動和context.xmlTomcat相應(yīng)目錄下

          test-all

          運行所有用于測試dao, serviceweb的測試用例

          test-dao

          測試dao模塊

          test-service

          測試service模塊

          test-web

          使用Mocks測試Action/Controller (不需要容器)

          test-jsp

          Tomcat中運行Canoo WebTest (啟動/停止Tomcat, 執(zhí)行前Tomcat應(yīng)該被停止)

          test-canoo

          Tomcat已經(jīng)運行時,執(zhí)行Canoo WebTest

          test-reports

          產(chǎn)生測試報告

          undeploy

          $CATALINA_HOME/webapps中刪除war文件和相應(yīng)的目錄

          posted @ 2005-11-11 14:14 似水流年 閱讀(427) | 評論 (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&amp;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 似水流年 閱讀(657) | 評論 (0)編輯 收藏
          Java 中對文件的讀寫操作之比較
          一.在 JDK 1.0 中,通常是用 InputStream & OutputStream 這兩個基類來進行讀寫操作的。
          InputStream 中的 FileInputStream 類似一個文件句柄,通過它來對文件進行操作,類似的,在
          OutputStream 中我們有 FileOutputStream 這個對象。

          用FileInputStream 來讀取數(shù)據(jù)的常用方法是:
          FileInputStream fstream = new FileInputStream(args[0]);
          DataInputStream in = new DataInputStream(fstream);
          用 in.readLine() 來得到數(shù)據(jù),然后用 in.close() 關(guān)閉輸入流。
          完整代碼見 Example 1。

          用FileOutputStream 來寫入數(shù)據(jù)的常用方法是:
          FileOutputStream out out = new FileOutputStream("myfile.txt");    
          PrintStream p = new PrintStream( out );
          用 p.println() 來寫入數(shù)據(jù),然后用 p.close() 關(guān)閉輸入。
          完整代碼見 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() 來讀出數(shù)據(jù),然后用br.close() 關(guān)閉緩存,用fr.close() 關(guān)閉文件。
          完整代碼見 Example 3。

          用 FileWriter 來寫入文件的常用方法是:
          FileWriter fw = new FileWriter("mydata.txt");
          PrintWriter out = new PrintWriter(fw);  
          在用out.print 或 out.println 來往文件中寫入數(shù)據(jù),out.print 和 out.println的唯一區(qū)別是后者寫
          入數(shù)據(jù)或會自動開一新行。寫完后要記得 用out.close() 關(guān)閉輸出,用fw.close() 關(guān)閉文件。   
          完整代碼見 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 似水流年 閱讀(907) | 評論 (2)編輯 收藏
          主站蜘蛛池模板: 若尔盖县| 成都市| 吉林市| 吴江市| 越西县| 神木县| 达日县| 清苑县| 兰西县| 美姑县| 兴业县| 滁州市| 万全县| 宜君县| 大悟县| 五河县| 永年县| 思茅市| 濉溪县| 门头沟区| 龙川县| 沽源县| 咸丰县| 维西| 常州市| 错那县| 太原市| 延吉市| 诸城市| 吴旗县| 新乐市| 广东省| 龙川县| 鲁山县| 民权县| 嵊泗县| 克东县| 昌图县| 城步| 健康| 元谋县|