当前位置: 技术问答>unix/linux知识
iis7站长之家
把這個類改成Java Bean應該怎樣改?
来源: 互联网 发布时间:2015-06-29
本文导语: public class OfficeSystem{ private Vector v; public OfficeSystem(){ v=new Vector(); } public void addAccount(Account a){ a.setOs(this); Account ac=getAccount(a.getUserId()); if(ac==null) v.addElement(a); else ac=a; } public void removeAccount(Account ...
public class OfficeSystem{
private Vector v;
public OfficeSystem(){
v=new Vector();
}
public void addAccount(Account a){
a.setOs(this);
Account ac=getAccount(a.getUserId());
if(ac==null) v.addElement(a);
else ac=a;
}
public void removeAccount(Account a){
v.removeElement(a);
}
public int getCount(){
return v.size();
}
public boolean existsAccount(String userid){
Enumeration e=v.elements();
while(e.hasMoreElements()){
Account a=(Account)(e.nextElement());
if(a.getUserId().equals(userid)) return true;
}
return false;
}
public Account getAccount(String userid){
Enumeration e=v.elements();
while(e.hasMoreElements()){
Account a=(Account)(e.nextElement());
if(a.getUserId().equals(userid)) return a;
}
return null;
}
public Account[] getAccount(){
int count=v.size();
if(count==0) return null;
Account rs[]=new Account[count];
Enumeration e=v.elements();
int i=0;
while(e.hasMoreElements()){
rs[i]=(Account)(e.nextElement());
i++;
}
return rs;
}
public void sendMessage(String userid,String message){
Account ac=getAccount(userid);
ac.addMessage(message);
}
}
private Vector v;
public OfficeSystem(){
v=new Vector();
}
public void addAccount(Account a){
a.setOs(this);
Account ac=getAccount(a.getUserId());
if(ac==null) v.addElement(a);
else ac=a;
}
public void removeAccount(Account a){
v.removeElement(a);
}
public int getCount(){
return v.size();
}
public boolean existsAccount(String userid){
Enumeration e=v.elements();
while(e.hasMoreElements()){
Account a=(Account)(e.nextElement());
if(a.getUserId().equals(userid)) return true;
}
return false;
}
public Account getAccount(String userid){
Enumeration e=v.elements();
while(e.hasMoreElements()){
Account a=(Account)(e.nextElement());
if(a.getUserId().equals(userid)) return a;
}
return null;
}
public Account[] getAccount(){
int count=v.size();
if(count==0) return null;
Account rs[]=new Account[count];
Enumeration e=v.elements();
int i=0;
while(e.hasMoreElements()){
rs[i]=(Account)(e.nextElement());
i++;
}
return rs;
}
public void sendMessage(String userid,String message){
Account ac=getAccount(userid);
ac.addMessage(message);
}
}
|
其实这个不用该就ok了,将此文件的编译成 .class文件放到相应目录的WEB_INFclasses 下即可;
在jsp里面如此调用就可以了
成功了不要忘了给分哦
在jsp里面如此调用就可以了
成功了不要忘了给分哦
|
不用改的啊
在jsp页面里把这个类import进来,然后就可以使用了;
在jsp页面里把这个类import进来,然后就可以使用了;
|
再加上 setV() 和getV()吧