| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 471 人关注过本帖
标题:javaweb问题求解
只看楼主 加入收藏
瞬间永恒
Rank: 1
等 级:新手上路
帖 子:2
专家分:4
注 册:2014-4-2
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
javaweb问题求解
package lab1_1;

import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
import

public class limitstudent implements Serializable {
String name;
int age;
VetoableChangeSupport vcSupport;
String university;

public limitstudent() {
    setName("tom");
    setAge(21);
    vcSupport=new VetoableChangeSupport(this);
    setUniversity("GZU");
}
public void _tostring(){
    System.out.println(" personal information:"+name+" "+age+" "+university);
}
public String getName() {
    return name;
}
public void setName(String s) {
    this.name = s;
}

public void setAge(int i) {
    int old;
    old= age;
    try {
        vcSupport.fireVetoableChange("age",old,i);
        age=i;
    } catch (PropertyVetoException e) {
        System.out.println(e);
        
    }
        
   
}
public int getAge() {
    return age;
}
public String getUniversity() {
    return university;
}
public void setUniversity(String s1) {
    this.university = s1;
}
public void addVetoableChangeListener(VetoableChangeListener vc1){
    vcSupport.addVetoableChangeListener(vc1);
}
public void removeVetoableChangeListener(VetoableChangeListener vc1){
    vcSupport.removeVetoableChangeListener(vc1);
}
}






package lab1_1;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;

public class testlimitstudent {

    public testlimitstudent(){}
    public static void main(String[] args) {
        limitstudent st=new limitstudent();
        System.out.println("初始信息:");
        st._tostring();
        st.addVetoableChangeListener(new VetoableChangeListener() {
            
            @Override
            public void vetoableChange(PropertyChangeEvent e)
                    throws PropertyVetoException {
            if (Integer.parseInt((e.getNewValue()).toString())<=20)
            throw(new PropertyVetoException("年龄太小"+e.getNewValue(),e));   
            }
               
            
        });
        st.setAge(19);
        System.out.println("最后信息:");
        st._tostring();
    }

}



怎么破?
Exception in thread "Main Thread" java.lang.NullPointerException
    at lab1_1.limitstudent.setAge(limitstudent.java:34)
    at lab1_1.limitstudent.<init>(limitstudent.java:16)
    at lab1_1.testlimitstudent.main(testlimitstudent.java:11)
搜索更多相关主题的帖子: university package javaweb public import 
2014-04-02 14:54
szgg520
Rank: 5Rank: 5
等 级:职业侠客
威 望:3
帖 子:79
专家分:307
注 册:2011-6-13
收藏
得分:7 
空指针异常而已...

[url=http://www.]深圳复印机出租[/url]
2014-04-04 20:47
jiewen
Rank: 2
等 级:论坛游民
威 望:1
帖 子:5
专家分:17
注 册:2014-4-1
收藏
得分:7 
为什么在myeclipse中运行servlet时, 浏览器直接显示下载页面,而不是直接在网页中直接显示内容,求大神指点
2014-04-06 11:02
java程序员
Rank: 1
等 级:新手上路
帖 子:3
专家分:7
注 册:2014-4-8
收藏
得分:0 
回复 3楼 jiewen
你跟断点啊!数据库里的必填项你在main方法里没有給值。。。
2014-04-08 10:44
快速回复:javaweb问题求解
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031564 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved