■ 참고 : http://www.mkyong.com/servlet/what-is-listener-servletcontextlistener-example/
■ ServletContextLister를 구현하면 웹 애플리케이션이 시작된 직후에 필요한 작업을 할 수 있다.
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.springframework.beans.factory.annotation.Autowired; public class StartupListener implements ServletContextListener { /** * 웹 애플리케이션 시작 */ @Autowired public void contextInitialized(ServletContextEvent event) { System. out.println( "StartupListener..." ); } /** * 웹 애플리케이션 종료 */ public void contextDestroyed(ServletContextEvent arg0) {} }
■ StartupListener를 web.xml에 등록한다.
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> ... <listener> <listener-class>net.iotinfra.pilot.listener.StartupListener</listener-class> </listener> ... </web-app>
- SpringBoot Port 변경 2022년 12월 27일
- Spring 트랜잭션 관리 2019년 6월 20일
- Spring RESTful 웹 서비스 사용하기 2019년 6월 19일
- Spring RESTful 웹 서비스 2019년 6월 19일
- Spring Scheduling Task 예제 2019년 6월 18일
- Tomcat : consider increasing the maximum size of the cache 2019년 3월 4일
- Tomcat Startup timeout error in Eclipse 2018년 5월 24일
- Tomcat 시작시 ServletContextListener를 통한 mySQL 접속 2018년 5월 8일
- spring mybatis mysql 연결 예제 2018년 5월 4일
- Spring Path Parameter 예제 2018년 2월 13일
- AngularJS $http, spring TEXT response 예제 2018년 1월 17일
- jdom2를 이용한 spring xml response(응답) 2017년 12월 5일
- jquery xml 요청, spring xml 리턴 2017년 12월 5일
- spring controller에서 get, post 동시 허용 방법 2017년 12월 5일
- mybatis, oracle procedure(오라클 커서)를 통한 데이터 조회 2017년 11월 6일
- HTTP 406 Not Acceptable in Spring, Jackson, Json 2017년 11월 6일
- ServletContextLister를 구현한 웹 애플리케이션 시작 시 작업 2016년 5월 2일
- Web Application MessageResource 2016년 3월 8일
- tomcat-maven-plugin을 통한 maven tomcat배포 2016년 2월 23일
- tomcat java.lang.OutOfMemoryError: PermGen space 2016년 2월 23일
- org.mariadb.jdbc.internal.common.QueryException : No database selected 2016년 2월 19일
- jquery spring – checkbox로 선택된 배열 주고 받기 2015년 8월 15일
- jquery spring ajax call 2015년 8월 15일
- spring json return 2015년 8월 15일
- spring exception – SimpleMappingExceptionResolver 2015년 8월 8일
- Tomcat https 서비스(SSL, keystore) 2015년 7월 26일