int temp =(这里应该填什么啊??)session.getAttribute("temp");

解决方案 »

  1.   

    int tempS =(String)session.getAttribute("temp");
    int temp =Integer.parseInt(tempS);
      

  2.   

    和你session.setAttribute(key, value)执行时value的类型有关
    value:Integer, int temp = ((Integer)session.getAttribute("temp")).intValue();
    value:String,  int temp = Integer.parseInt((String)session.getAttribute("temp"));
      

  3.   

    填你设置session.setAttribute("temp", type);
    type的原型
      

  4.   

    session.getAttribute("temp"); 返回的是字符串
      

  5.   

    来晚了。晚了。。楼上的楼上错了。
    String tempS =(String)session.getAttribute("temp");//是String
    int temp =Integer.parseInt(tempS);
      

  6.   

    Integer.parse((String)session.getAttribute("temp"))
    转换为整型
      

  7.   

    int是原始类型,而session得到的是对象引用。不可能有这样的转换。
    先转换为int的包装类Integer,然后调用Integer类的intValue;
    int i = ((Integer)session.getAttribute("aNum")).intValue;
      

  8.   

    当然,前提是你放入session的类型必须是Integer的。如果是String的,那么建议你在放入前先作类型转换,不要在取出的时候做。
    这样的话对于你的对象有一段时间会不是类型安全的。
    如果你就是要放String,那就
    String tempS =(String)session.getAttribute("temp");//是String
    int temp =Integer.parseInt(tempS);