您的位置:首页 > 其它

关于 Type mismatch: cannot convert from Integer to int

2016-10-15 22:06 561 查看
        Integer count=1;

会报Type mismatch: cannot convert from int to Integer。

这是因为我用的jdk是1.8版本的,编译器 用的1.6版本编译,myeclipse6.5,没有1.7版本的编译器可以选择了,我又不想重装myeclipse,因为太麻烦了。所有我就用用自己的方式去解决了问题。

HttpSession  session=request.getSession();

        System.out.println("sessionId:"+session.getId());

        Integer count= (Integer) session.getAttribute("count");

        if(count==null){

            count=new Integer(1); //  Integer count=0

        }else{

            count=new Integer(count.intValue()+1);

        }

        session.setAttribute("count", count);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息