This question already has answers here:
What is a NullPointerException, and how do I fix it?
                                
                                    (12个答案)
                                
                        
                                2年前关闭。
            
                    
下面的空检查语句如何引发Nullpointer异常?该请求可能为空吗?我很困惑有人帮忙。

if(!getTGTid(request).equalsIgnoreCase(null) ||
!getTGTid(request).equalsIgnoreCase("")) {


方法

private String getTGTid(HttpServletRequest request) {
return request.getParameter("tgtId");
}

最佳答案

如果getTGTid(request)为null,则getTGTid(request).equalsIgnoreCase(null)将抛出NullPointerException

使用

if (getTGTid(request) != null && !getTGTid(request).equalsIgnoreCase(""))

07-24 13:21