java技术博客

jsp博客
数据加载中……

2009年1月17日

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 郭兴华 阅读(329) | 评论 (0)编辑 收藏

2009年1月12日

上海交通大学java视频教程共31讲

上海交通大学java视频教程共31讲
If you are interested in java, you can spend time learning about it

posted @ 2009-01-12 22:17 郭兴华 阅读(576) | 评论 (0)编辑 收藏

2008年11月13日

*.class 如何打包

先放下吧

posted @ 2008-11-13 09:12 郭兴华 阅读(163) | 评论 (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 郭兴华 阅读(364) | 评论 (0)编辑 收藏
java中的集合

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

posted @ 2008-11-13 09:07 郭兴华 阅读(268) | 评论 (0)编辑 收藏

2008年11月7日

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 郭兴华 阅读(210) | 评论 (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 郭兴华 阅读(268) | 评论 (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 郭兴华 阅读(319) | 评论 (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 郭兴华 阅读(495) | 评论 (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 郭兴华 阅读(4590) | 评论 (0)编辑 收藏
仅列出标题  下一页