Jump on "Spring"......

How to initialize the Spring Application Context

Configuration in Web.xml

  <param-value>/WEB-INF/daoContext.xml  /WEB-INF/mainApp-context.xml  /WEB-INF/applicationContext.xml


multiple context file can be given separated by space or single context file which could import other context files in it.
One more option is there to load context with help of context loader servlet in-spite of listener as below.

<servlet> <servlet-name>context</servlet-name> 

The listener inspects the 'contextConfigLocation' parameter. If the parameter does not exist, the listener will use /WEB-INF/applicationContext.xml as a default. When it does exist, it will separate the String using predefined delimiters (comma, semi-colon and whitespace) and use the values as locations where application contexts will be searched for. Ant-style path patterns are supported as well: e.g. /WEB-INF/*Context.xml (for all files whose name ends with "Context.xml", residing in the "WEB-INF" directory) or /WEB-INF/**/*Context.xml (for all such files in any subdirectory of "WEB-INF")

In Main App Context multiple context files can be imported as below. Property place holder is used to load 
properties present in application properties like server, port,url,base


  <property name="url">
  <property name="base">


<import resource="Db-context.xml" />
<import resource="Beans-context.xml" />
<import resource="Mq-context.xml" />

<bean id="propertyPlaceholderConfigurer"
<property name="locations">
<property name="ignoreUnresolvablePlaceholders">



Connect Spring context with Struts

In struts config.xml specify pulgin  with  ccontext file have action class bean;

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/springappContext-servlet.xml" />

define action mapping in struts config as 

<action path="/Login" name="LoginActionForm" scope="request" 
type="org.springframework.web.struts.DelegatingActionProxy" parameter="methodName">
 <forward name="success" path="/MenuSelection.do?methodName=displayScreen" />
 <forward name="error" path="/jsp/Login.jsp" />


Popular posts from this blog

Conversion from Clob To String in java and Vice versa

Portable Java 8/ JDK8 setup without admin rights

Multi Threading , Producer consumer problem in Java