Servlet3.0的註解原生Listener監聽器
阿新 • • 發佈:2018-12-18
自定義Listener(常用的監聽器 servletContextListener、httpSessionListener、servletRequestListener)
@WebListener
public class RequestListener implements ServletRequestListener {
@Override
public void requestDestroyed(ServletRequestEvent sre) {
// TODO Auto-generated method stub
System.out.println("======requestDestroyed========");
}
@Override
public void requestInitialized(ServletRequestEvent sre) {
System.out.println("======requestInitialized========");
}
啟動類裡面需要加@ServletComponentScan註解,讓spring掃描