본문 바로가기

Spring Framework

dispatcher-servlet, applicationContext.xml 파일 경로수정

개요 :

   

인텔리제이 경우 최초 스프링 기본 구조상

dispatcher-servlet, applicationContext.xml 파일이 WEB-INF 아래에 위치함

 

파일 위치 변경방법

 

web.xml

 

<!-- applicationContext.xml 파일 위치경로를 resources/context/.. 에 설정하겠다 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:/context/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


<!-- dispatcher-servlet.xml 파일 위치경로를 resources/context/.. 에 설정하겠다 -->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:context/*.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

 

기존 WEB-INF 아래 파일을 <param-value> 부분보면 classpatch:context/*.xml 로 되어있음

 

classpatch = resources

 

resources / context / ... .xml 을 읽겠다란 뜻