public class Myfp implements javax.servlet.http.HttpSessionBindingListener{ public String[] myfp_ygfp_sl; public Integer[] myfp_ygfp_mc; public int i=0;
public String getString(){ return "str"; } //constructor public void Myfp(){ this.myfp_ygfp_sl=new String[3]; this.myfp_ygfp_mc=new Integer[3];
public void Myfp(){
~~~~~constructor 是不能有返回值的。估计错误是这个原因导致的。
~~~~~改为public Myfp() {再试试看。
........
}再试试看。
to ejbcreate() ,我试过了,问题没就决阿!
难怪看着有点别扭,呵呵。
你没全贴出来,只能先判断一下:
你现在的”myfp.myfp_ygfp_mc[0]“感觉只是个标识符,和abcde...没什么区别。以下参考一下:
session.setAttribute("arrMyfp",myfp.myfp_ygfp_mc[0]);
Integer intMyfp=session.getAttribute("arrMyfp");
......
然后再Myfp bb=session.getAttribute("arrMyfp");
如果是这样,是有办法的。
BTW, 怎么散分啊,我虽然只有200,但希望给大家热心人每人20分,还有怎么封贴啊,我在管理里面没找到啊。
public String[] myfp_ygfp_sl;
public Integer[] myfp_ygfp_mc;
public int i=0;
public String getString(){
return "str";
}
//constructor
public void Myfp(){
this.myfp_ygfp_sl=new String[3];
this.myfp_ygfp_mc=new Integer[3];
for(int i=0;i<3;i++)
{this.myfp_ygfp_sl[i]=new String("0");
this.myfp_ygfp_mc[i]=new Integer(i);
}
}
public void valueBound(HttpSessionBindingEvent aEvent){}
public void valueUnbound(HttpSessionBindingEvent aEvent){}
}//Myfp.java
------------------------------------------
<% page import="Myfp"%>
<%
session.setAttribute("myfp",Myfp);
Myfp my=session.getAttribute("myfp");
Integer i=my.myfp_ygfp_mc[0];
String s=my.myfp_ygfp_sl[0];
int j=my.i;
String s2=my.getString();
%>够清楚了咯。
另外HttpSessionBindingEvent ,HttpSessionBindingEvent自己import,别忘了 。在jsp中还可以这样定义:
String[] arr=my.myfp_ygfp_sl;
Integer[] intArr=my.myfp_ygfp_mc;这样应该可以了,好运!