16 Aralık 2021 Perşembe

Servlet ServletContextAttributeListener Arayüzü

Giriş
Şu satırı dahil ederiz
import javax.servlet.ServletContextAttributeListener;
Açıklaması şöyle
The ServletContextAttributeListener interface is for receiving notification events about ServletContext attribute changes. The order in which its implementations are invoked is unspecified.
Örnek
Şöyle yaparız
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class MyServletContextAttributeListener implements ServletContextAttributeListener {

  public void attributeAdded(ServletContextAttributeEvent event) {
    System.out.println("context attr " + event.getName() + " added with value " +
event.getValue());
  }

  public void attributeRemoved(ServletContextAttributeEvent event) {
    System.out.println("context attr " + event.getName() + " removed with value " +
event.getValue());
  }

  public void attributeReplaced(ServletContextAttributeEvent event) {
    System.out.println("context attr " + event.getName() + " replaced with value " +
event.getValue());
  }
}

Hiç yorum yok:

Yorum Gönder

Bean Validation @GroupSequence Anotasyonu

Örnek Elimizde şöyle bir kod olsun public class SampleRequest {   @NotNull   LocalDate startDate;   @NotNull   LocalDate endDate;   @AssertT...