Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring servlet in web.xml with missing contextConfigLocation param-value

Tags:

spring-mvc

I have a web.xml file with (among other things) a servlet that defines an init-param to specify the contextConfigLocation, but the param-value is BLANK?

Why is the developer doing this. I can't for the life of me find anything in the documentations for Spring 3.X that tells me what effect this has.

<servlet>
    <servlet-name>restservices</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
like image 850
user3263992 Avatar asked Oct 15 '25 08:10

user3263992


2 Answers

By default the DispatcherServlet will load a xml file named [servlet-name]-servlet.xml.

This is when no init-param named contextConfigLocation is defined.

However in your case there is an init-param named contextConfigLocation defined, which tells the DispatcherServlet to load nothing but only delegate to the parent context (the one loaded by the ContextLoaderListener).

So in short there is a difference between no init-param defined or an empty init-param.

See also https://jira.springsource.org/browse/SPR-4746.

like image 157
M. Deinum Avatar answered Oct 18 '25 08:10

M. Deinum


it just because the developer had nothing to declare in the servlet configuration. he had maybe defined all what he needs in the root context.

like image 21
storm_buster Avatar answered Oct 18 '25 06:10

storm_buster