已采納回答 / 不逃課
因為doFilter()方法中的參數arg0是ServletRequest類型的,而不是HttpServletRequest類型。而HttpServletRequest是ServletRequest的子類,所以先要強制類型轉換HttpServletRequest request = (HttpServletRequest) arg0;
2016-03-03
已采納回答 / sxian_wang
單就樓主的這份代碼而言,我在我本機上跑了一下,是完全沒有問題的。<...圖片...>所以樓主的問題不在這里。要么是web.xml注冊Filter的時候出了問題,要么就是一開始請求的那個頁面出了問題...
2015-12-10
已采納回答 / 無動于衷
當數組存儲的是 類的對象,而不是基本數據類型時,可能發生。因為數組在定義時,都有默認值,基本數據類型默認是“數”,比如 int[] a=new int[];a[i]默認都為0;而引用類型(累的對象)的默認值則是null;Student[] strArray = new Student[5];Student t1 = new Student();Student t2 = new Student();Student t3 = new Student();Student t4 = new Student();s...
2015-09-18
講師回答 / Fcming
您好,重新創建是為了獲取http中的request,可以獲取相關的方法,如getContextPath。原來的參數ServletRequest是無法獲取的。
2015-09-15