session.setAttribute(str1,str2)
session.getAttribute(str1)

解决方案 »

  1.   

    DBID现在是int类型的啊,我用session.setAttribute("DBID",DBID);
    <------------------------------->
    *** Error: No match was found for method "setAttribute(java.lang.String, int)".
      

  2.   

    session.setAttribute("DBID",String.valueOf(DBID));

    session.setAttribute("DBID",new Integer(DBID));
    等等
    不能是基本类型
      

  3.   

    setAttribute不能使用int的,要用object,可以转成String或Integer,到时候再转回来.
      

  4.   

    非常感谢freefalcon(心宇),高手啊。
    另外想请教一下,在接受页,怎么取出session值给变量呢?
    我用String se1 = session.getAttribuet("DBID");
    总是报错<--------------------------------->
    *** Error: The type of the left-hand side in this assignment, "java/lang/String", is not compatible with the type of the right-hand side expression, "java/lang/Object".
    汗~~~~~
      

  5.   

    String se1 = (String)session.getAttribuet("DBID");需强制转换
      

  6.   

    偶会了,呵呵
    先用session.setAttribute("coId",String.valueOf(coID));
    再用String dbid = String.valueOf(session.getAttribute("coId"));转换回来,呵呵,多谢了~~~