「Spring mvc入門」インタフェースServletContextListenerを実装するコード
javaコード
public class AnnotationListener implements ServletContextListener{
private ServletContext servletContext;
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
List<String> list = new AnnotationUtil().getRequestMapping();
this.servletContext = servletContextEvent.getServletContext();
servletContext.setAttribute(“annotationList",list);
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
}
}
使い方
getServletContext().getAttribute(“annotationList");