在加入session.setAttribute("type",level)时候  这个level是string类型的数字1,2..
但是在得到的时候int a=((Integer)session.getAttribute("type")).intValue();
然后在判断if(a==1)或者if(a==2)但是抱错不是很明白那里错了,,开始我用string类型的,但是判断不了..希望高手帮下...或者告诉我该怎么做..我要判断这个取出来的数是多少...

解决方案 »

  1.   

    int a=Interger.parseInt(session.getAttribute("type"));
    如果以上还行的话,就:
    int a=Interger.parseInt(String.valueOf(session.getAttribute("type")));
    然后:
    if(a==1)
    ...
    ...
      

  2.   

    set的时候改integer??有什么不同么?
      

  3.   

    不是set时候interger,看清楚,是session.getAttribute("type"),是get
    问题解决了吗?
      

  4.   

    2楼的请问下
    你的下面的方法int a=Integer.parseInt(String.valueOf(session.getAttribute("type")));
    可以..能解释下为什么吗?
      

  5.   

    为什么要先转为string类型的呢?...