Results 1 to 2 of 2

Thread: loading of properties into DispatcherServlet ..

  1. #1
    Join Date
    Mar 2007
    Posts
    17

    Default loading of properties into DispatcherServlet ..

    hi Folks,

    when I'm trying to inject a bean with String Property it is not loading the property correctly. I have the following config ...

    Code:
    web.xml : 
    <context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			/WEB-INF/classes/applicationContext.xml
    	        </param-value>
    	</context-param>
    <listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    .
    .
    .
    .
    .
    <servlet>
    		<servlet-name>frontController</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>2</load-on-startup>
    	</servlet>
    <servlet-mapping>
    		<servlet-name>frontController</servlet-name>
    		<url-pattern>/frontController/*</url-pattern>
    	</servlet-mapping>
    
    frontController-servlet.xml : 
     	<bean id="search" class="com.web.action.Search">
    	 	<property name="serviceUrl"><value>${ServletPath}?${ReportUnit}&amp;format=xls&amp;KEY=</value></property>		
     	</bean>
    My applicationContext.xml has the following ..
    Code:
    applicationContext
    <beans>
    	<bean name="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        	<property name="locations">
            	<list>
    	        <value>classpath:Reports.properties</value>
            	</list>
    	    </property>
    	</bean>
    </beans>
    In the Reports.properties I've the following ...

    Code:
    Reports.properties 
    
    ReportUnit=DetailsExportReport
    ServletPath=/NWE/jasper
    Into my bean I'm only getting "${ServletPath}?${ReportUnit}&format=xls&KEY=" and not "/NWE/jasper?DetailsExportReport&format=xls&KEY=" which is what I want ...

    Does anyone know where am I going wrong?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    It is all in the reference guide . Read chapter 3 about the container.

    Bean(Factory)PostProcessor only post process beans in the same container they are defined in, not on child contexts. So in your case you also need to specify a PropertyPlaceHolderConfigurer in your frontController-servlet.xml.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •