session.getAttribute()应该只能建一些简单的数据类型比如String,Integer等。
至于数组,我也没这样用过,应该是不能这样用的。想其他办法吧.

解决方案 »

  1.   

    //constructor
    public void Myfp(){
    ~~~~~constructor 是不能有返回值的。估计错误是这个原因导致的。
      

  2.   

    public void Myfp(){
    ~~~~~改为public Myfp() {再试试看。
      

  3.   

    改为public Myfp() {
    ........
    }再试试看。
      

  4.   

    感谢楼上,但问题没有解决阿,To wssg(我很傻-可是我很努力) ,我不是用getattribute 来执行程序,只是因myfp.myfp_ygfp_mc[0]=new Integer(1);赋值出错,提示空指针才用getAttribute来检查的,返回确实为空:
    to  ejbcreate() ,我试过了,问题没就决阿!
      

  5.   

    但数组元素没有,(session.getAttribute("myfp.myfp_ygfp_mc[0]")==null)为True.
    难怪看着有点别扭,呵呵。
    你没全贴出来,只能先判断一下:
    你现在的”myfp.myfp_ygfp_mc[0]“感觉只是个标识符,和abcde...没什么区别。以下参考一下:
    session.setAttribute("arrMyfp",myfp.myfp_ygfp_mc[0]);
    Integer intMyfp=session.getAttribute("arrMyfp");
    ......
      

  6.   

    session.setAttribute("arrMyfp",myfp)
    然后再Myfp bb=session.getAttribute("arrMyfp");
      

  7.   

    TO:everzerg(虫子) 你是不是想把class或者array放入session?
    如果是这样,是有办法的。
      

  8.   

    谢谢楼上的兄弟。大家都没看懂,说明我对问题描述不清,简单来说,谁示范一下定义一个数组,并给这给数组赋值,最好数组元素类型不要是简单数据类型,而是一个自定义的类,包括一个string,和一个int field.
    BTW, 怎么散分啊,我虽然只有200,但希望给大家热心人每人20分,还有怎么封贴啊,我在管理里面没找到啊。
      

  9.   

    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];

    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();
    %>够清楚了咯。
      

  10.   

    sorry:public void Myfp()改为public Myfp(){
      

  11.   

    sorry,没有调试过。把session.setAttribute("myfp",Myfp);改为session.setAttribute("myfp",new Myfp());
    另外HttpSessionBindingEvent ,HttpSessionBindingEvent自己import,别忘了 。在jsp中还可以这样定义:
    String[] arr=my.myfp_ygfp_sl;
    Integer[] intArr=my.myfp_ygfp_mc;这样应该可以了,好运!