What is the method signature for an event where an attribute was removed from an HttpSession?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "public void attributeRemoved(HttpSessionBindingEvent event)". Giao diện HttpSessionAttributeListener định nghĩa ba móc cho thuộc tính của phiên là attributeAdded, attributeReplaced và attributeRemoved; cả ba nhận một HttpSessionBindingEvent, nhờ đó mã lắng nghe lấy được phiên, tên thuộc tính và giá trị vừa bị tháo khỏi phiên. "public void attributeDeleted(HttpSessionBindingEvent event)" dùng đúng kiểu sự kiện nhưng sai tên móc, nên container không bao giờ gọi tới. "public void removeAttribute(HttpSessionBindingEvent event)" lấy tên của hành động trên HttpSession, tức phương thức mà mã ứng dụng gọi để xoá thuộc tính, chứ không phải tên móc báo lại sự việc đó. "public void sessionInvalidate(HttpSessionEvent event)" sai cả tên lẫn kiểu đối số: móc theo vòng đời phiên nằm ở giao diện lắng nghe phiên với cặp sessionCreated và sessionDestroyed.
Cùng phần 11
Which method of the ServletContextListener interface is called when the ServletContext is initialized?Có lời giảiCâu hỏiWhich listener helps to monitor the changes in the values of session variables?Có lời giảiCâu hỏiWhich of the following events is typically handled by a ServletContextListener?Có lời giảiCâu hỏiCả 20 câu của chủ đề20 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây