java技術博客

          jsp博客
          數據加載中……

          2008年11月5日

          jquery的ajax應用

          //定義用戶名校驗的方法
          function verify(){
              
          //首先測試一下頁面的按鈕按下,可以調用這個方法
              //使用javascript的alert方法,顯示一個探出提示框
              //alert("按鈕被點擊了!!!");

              
          //1.獲取文本框中的內容
              //document.getElementById("userName");  dom的方式
              //Jquery的查找節點的方式,參數中#加上id屬性值可以找到一個節點。
              //jquery的方法返回的都是jquery的對象,可以繼續在上面執行其他的jquery方法
              var jqueryObj = $("#userName");
              
          //獲取節點的值
              var userName = jqueryObj.val();
              
          //alert(userName);

              
          //2.將文本框中的數據發送給服務器段的servelt
              //使用jquery的XMLHTTPrequest對象get請求的封裝
              $.get("AJAXServer?name=" + userName,null,callback);


          }


          //回調函數
          function callback(data) {
          //    alert("服務器段的數據回來了!!");
              //3.接收服務器端返回的數據
          //
              alert(data);
              //4.將服務器段返回的數據動態的顯示在頁面上
              //找到保存結果信息的節點
              var resultObj = $("#result");
              
          //動態的改變頁面中div節點中的內容
              resultObj.html(data);
              alert(
          "");
          }

          posted @ 2009-01-17 16:35 郭興華 閱讀(344) | 評論 (0)編輯 收藏
          上海交通大學java視頻教程共31講

          上海交通大學java視頻教程共31講
          If you are interested in java, you can spend time learning about it

          posted @ 2009-01-12 22:17 郭興華 閱讀(594) | 評論 (0)編輯 收藏
          *.class 如何打包

          先放下吧

          posted @ 2008-11-13 09:12 郭興華 閱讀(169) | 評論 (0)編輯 收藏
          java中的printf

          public class TestPrintf{
              
          public static void main(String args[]){
                  System.out.printf(
          "%+8.3f",3.14);    
                  System.out.println();            
                  System.out.printf(
          "%+-8.3f\n",3.14);
                  System.out.printf(
          "%08.3f\n",3.14);
                  System.out.printf(
          "%(8.3f\n",-3.14);
                  System.out.printf(
          "%,f\n",2356.34);
                  System.out.printf(
          "%x\n",0x4a3b);
                  System.out.printf(
          "%#x\n",0x4a3b);        
                  System.out.println(
          "------------");    
                  System.out.printf(
          "你好:%s,%3d歲,工資%-7.2f\n","張三",38,15000.00);        
                  System.out.printf(
          "你好:%1$s,%2$3d歲,%2$#x歲\n","張三",38);        
                  System.out.printf(
          "%3d,%#<x",38);
              }
              
          }

          posted @ 2008-11-13 09:09 郭興華 閱讀(381) | 評論 (0)編輯 收藏
          java中的集合

               摘要: Integer[] a = {3,25,12,79,48};         System.out.println(a);         System.out.println(Arrays.toStrin...  閱讀全文

          posted @ 2008-11-13 09:07 郭興華 閱讀(285) | 評論 (0)編輯 收藏
          Arraylist

           

          /**
           * 測試數組列表的使用
           
          */

           
          import java.util.ArrayList;

          public class ArrayListTest
          {
              
          public static void main(String[] args)
              
          {
                  ArrayList list 
          = new ArrayList();
                  list.add(
          new Student("Tom","20020410"));
                  list.add(
          new Student("Jack","20020411"));
                  list.add(
          new Student("Rose","20020412"));

                  
          for(int i = 0; i < list.size(); i++)
                  
          {
                      System.out.println((Student)list.get(i));
                  }

              }

          }


          class Student
          {
              
          private String strName = "";//學生姓名
              private String strNumber = "";//學號
              private String strSex = "";//性別
              private String strBirthday = "";//出生年月
              private String strSpeciality = "";//專業
              private String strAddress = "";//地址

              
          public Student(String name, String number)
              
          {
                  strName 
          = name;
                  strNumber 
          = number;
              }


              
          public String getStudentName()
              
          {
                  
          return strName;
              }


              
          public String getStudentNumber()
              
          {
                  
          return strNumber;
              }


              
          public void setStudentSex(String sex)
              
          {
                  strSex 
          = sex;
              }


              
          public String getStudentSex()
              
          {
                  
          return strSex;
              }


              
          public String getStudentBirthday()
                  
          {
                  
          return strBirthday;
              }


              
          public void setStudentBirthday(String birthday)
              
          {
                  strBirthday 
          = birthday;
              }


              
          public String getStudentSpeciality()
              
          {
                  
          return strSpeciality;
              }


              
          public void setStudentSpeciality(String speciality)
              
          {
                  strSpeciality 
          = speciality;
              }


              
          public String getStudentAddress()
              
          {
                  
          return strAddress;
              }


              
          public void setStudentAddress(String address)
              
          {
                  strAddress 
          = address;
              }


              
          public String toString()
              
          {
                  String information 
          = "學生姓名=" + strName + ", 學號=" + strNumber;  
                  
          if!strSex.equals("") )
                      information 
          += ", 性別=" + strSex;
                  
          if!strBirthday.equals(""))
                      information 
          += ", 出生年月=" + strBirthday;
                  
          if!strSpeciality.equals("") )
                      information 
          += ", 專業=" + strSpeciality;
                  
          if!strAddress.equals("") )
                      information 
          += ", 籍貫=" + strAddress;
                  
          return information;
              }

          }

          posted @ 2008-11-07 16:34 郭興華 閱讀(223) | 評論 (0)編輯 收藏
          java的動態多態

          /**
           * 通過本程序的測試,主要學習抽象類及子類,抽象方法的實現
           * 動態綁定,多態
           
          */

           
          import java.text.NumberFormat;

          public class AbstractTest
          {
              
          public static void main(String[] args)
              
          {
                  Person[] p 
          = new Person[2];
                  p[
          0= new Worker("Jack"1000);
                  p[
          1= new Student("Tom""Computer");
                  
                  
          for(int i = 0; i < p.length; i++)
                  
          {
                      Person people 
          = p[i];
                      System.out.println(people.getDescription());
                  }

              }

          }


          /**
           * 抽象類
           
          */

          abstract class Person
          {
              
          private String strName;

              
          public Person(String strName)
              
          {
                  
          this.strName = strName;
              }


              
          public String getName()
              
          {
                  
          return strName;
              }


              
          //抽象方法,返回人的描述
              public abstract String getDescription();
          }


          /**
           * 工人類,擴展了抽象類,并實現了抽象方法
           
          */

          class Worker extends Person
          {
              
          private double salary;
              
              
          public Worker(String strName, double s)
              
          {
                  
          super(strName);
                  salary 
          = s;
              }

              
              
          public String getDescription()
              
          {
                  NumberFormat formate 
          = NumberFormat.getCurrencyInstance();
                  
          return "the worker with a salary of " + formate.format(salary);
              }

          }


          /**
           * 學生類,擴展了抽象類,實現了抽象方法
           
          */

          class Student extends Person
          {
              
          private String strMajor;
              
              
          public Student(String strName, String strMajor)
              
          {
                  
          super(strName);
                  
          this.strMajor = strMajor;
              }

              
              
          public String getDescription()
              
          {
                  
          return "the student majoring in " + strMajor;
              }

          }

          posted @ 2008-11-07 16:31 郭興華 閱讀(280) | 評論 (0)編輯 收藏
          java中的HashMapTest

               摘要: /** *//**  * 通過這個程序,測試散列映像的存儲與遍歷,方法的使用  */ import java.util.HashMap; import java.util.Collection; import java.util.Iterator; import java.util.Set; public&nb...  閱讀全文

          posted @ 2008-11-07 16:12 郭興華 閱讀(330) | 評論 (0)編輯 收藏
          java中的treeset

          /**
           * 通過這個程序,測試樹集的添加元素的無序性與輸出的有序性
           
          */

           
          import java.util.TreeSet;
          import java.util.Iterator;

          public class TreeSetTest
          {
              
          public static void main(String[] args)
              
          {
                  TreeSet tree 
          = new TreeSet();
                  tree.add(
          "China");
                  tree.add(
          "America");
                  tree.add(
          "Japan");
                  tree.add(
          "Chinese");
                  
                  Iterator iter 
          = tree.iterator();
                  
          while(iter.hasNext())
                  
          {
                      System.out.println(iter.next());
                  }

              }

          }

          posted @ 2008-11-07 16:10 郭興華 閱讀(513) | 評論 (0)編輯 收藏
          java中的treemap

               摘要: /** *//**  * 通過這個程序,測試樹映像的使用,表目集合的遍歷  */ import java.util.TreeMap; import java.util.Map; import java.util.Iterator; import java.util.Set; public class&...  閱讀全文

          posted @ 2008-11-07 16:08 郭興華 閱讀(4605) | 評論 (0)編輯 收藏
          java中的vector

               摘要: /** *//** *//** *//**  * 我們設計的學生基本類  */ class Student {     private String strName = "";//學生姓名     ...  閱讀全文

          posted @ 2008-11-07 16:02 郭興華 閱讀(350) | 評論 (0)編輯 收藏
          記錄類被實例化的次數

          /*01*/public class classNumberDemo 
          /*02*/{
          /*03*/      public static int objNum=0;
          /*04*/      public classNumberDemo()
          /*05*/      {
          /*06*/          classNumberDemo.objNum++;
          /*07*/      }

          /*08*/      public void show()
          /*09*/      {
          /*10*/          System.out.println("the No."+classNumberDemo.objNum);
          /*11*/      }

          /*12*/      
          /*13*/        public static void main(String args[])
          /*14*/        {
          /*15*/             classNumberDemo p=null;
          /*16*/             p=new classNumberDemo();
          /*17*/             p.show();
          /*18*/             p=new classNumberDemo();
          /*19*/             p.show();
          /*20*/             p=new classNumberDemo();
          /*21*/             p.show();             
          /*22*/      }

          /*23*/}

          posted @ 2008-11-05 22:16 郭興華 閱讀(360) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 芒康县| 布拖县| 蕉岭县| 重庆市| 石首市| 琼结县| 五华县| 晋中市| 边坝县| 赤城县| 连江县| 东兰县| 涿鹿县| 三明市| 衢州市| 濮阳市| 上蔡县| 长泰县| 于都县| 鄂州市| 南雄市| 淮阳县| 襄樊市| 郯城县| 克东县| 芷江| 贞丰县| 揭东县| 盘锦市| 久治县| 赣州市| 杭锦旗| 基隆市| 唐河县| 澳门| 当涂县| 济南市| 天祝| 盘锦市| 修武县| 西畴县|