Search code examples
xmlspringcontext-configuration

What is use of contextconfiglocation in web.xml of Spring-based web-app?


In Spring, what is purpose of ContextConfigLocation and also InternalResourceViewResolver? I did't get the purpose of these classes.


Solution

  • contexConficLocation is using in web.xml file. This purpose is override the acctual or default XML file in user wish. It is comeing under the <contex-param> tag, for example

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/spring-config.xml,WEB-INF/spring-servlet.xml</param-value>
    </context-param>
    

    InternalResourceViewResolver using inside servlet.xml file it is comeing under the viewResolver bean.

    Example

    <beans>
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="WEB-INF/view/"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>
    </beans>