Spring 웹 개발 에서 의 응용

(1)웹 프로젝트 에서 spring 을 사용 하려 면 jar 패 키 지 를 가 져 와 야 합 니 다.spring-web-4.2.4.jar 패키지(2)웹.xml 파일 에 Listener 를 설정 합 니 다.
<listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    listener-class>
listener>

이 ContextLoader Listener 는 ServletContextListener 를 실현 합 니 다.이 listener 에서 서버 가 시 작 될 때 applicationContext 대상 을 실현 클래스 인 WebapplicationContext 이 고 대상 을 ServletContext 에 저장 합 니 다.(3)웹.xml 파일 에 applicationContext.xml 파일 의 위 치 를 설정 해 야 합 니 다.기본적으로 WEB-INF 디 렉 터 리 에서 applicationContext.xml 을 찾 습 니 다.applicationContext.xml 파일 이 기본 위치 에 없 으 면 웹.xml 파일 에서 설정 할 수 있 습 니 다.
param>
    <param-name>contextConfigLocationparam-name>
    <param-value>classpath:applicationContext.xmlparam-value>
param>

Classpath:applicationContext.xml 는 현재 프로젝트 의 클래스 경로 에서 applicationContext.xml 파일 을 찾 는 것 을 대표 합 니 다.contextConfigLocation 는 listener 에서 설명 하 는 상수 입 니 다.spring 프로필 의 위 치 를 설명 합 니 다.위 설정 을 통 해 웹 개발 에서 spring 프레임 워 크 를 사용 할 수 있 습 니 다.

좋은 웹페이지 즐겨찾기