Uncaught TypeError: Cannot read property 'username' of null常见错误

版权声明:本站所提供的文章资讯、软件资源、素材源码等内容均为本作者提供、网友推荐、互联网整理而来(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考,如有侵犯您的版权,请联系我,本作者将在三个工作日内改正。 https://blog.csdn.net/weixin_42323802/article/details/84349921

在一个web 向项目中,user登录状态显示模块,有一个异常:
Uncaught TypeError: Cannot read property ‘username’ of null

在这sdf里插入图片描述

是因为:username 空指针
检查user模块代码,发现判断错了

34

》修改如下:
sdf

     User user = (User) session.getAttribute("loginUser");
        if (user == null) { // bugyici
            resultInfo = new ResultInfo(false, null, null);
        } else {
            resultInfo = new ResultInfo(true, user, null);
        }
        return resultInfo;

猜你喜欢

转载自blog.csdn.net/weixin_42323802/article/details/84349921