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 án
Lờ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

Xuất hiện trong 1 bộ đề