当没选择checkbox的时候老师的代码成功进入循环体,我改了个顺序就报错了-----------------------------------------------String[] isUseCookies = request.getParameterValues("isUseCookie"); if(isUseCookies!=null&&isUseCookies.length>0)老师写的成功了----------------------------------------------- String[] isUseCookies = request.getParameterValues("isUseCookie"); if(isUseCookies.length>0&&isUseCookies!=null)这样写就报空指针错误了,why???-----------------------------------------------org.apache.jasper.JasperException: An exception occurred processing JSP page /dologin.jsp at line 3532: request.setCharacterEncoding("utf-8");33: //棣栧厛鍒ゆ柇鐢ㄦ埛鏄惁閫夋嫨浜嗚浣忕櫥褰曠姸鎬�34: String[] isUseCookies = request.getParameterValues("isUseCookie");35: if(isUseCookies.length>0&&isUseCookies!=null)36: {37: //鎶婄敤鎴峰悕鍜屽瘑鐮佷繚瀛樺湪Cookie瀵硅薄閲岄潰38: String username = URLEncoder.encode(request.getParameter("username"),"utf-8");
1 回答
已采纳
呦呦米
TA贡献90条经验 获得超59个赞
isUseCookies 应该先判断是字符串否为空,不为空再取length判断字符串长短。因为如果字符串为空,就是null,取它的length,就类似于数组越界,就是对一个不存在的对象取值,会报空指针异常。
添加回答
举报
0/150
提交
取消