java - Why isn't Spring injecting a map into a child Struts 2 Action class but parent's objects are injected? -


i have following configuration in spring applicationcontext.xml in order inject objects struts 2 java project:

<util:map id="typetourlmap">     <entry key="typea" value="./ur1.x" />     <entry key="typeb" value="./url2.x" />     <entry key="typec" value="./url3.x" />     <entry key="other" value="./url4.x" /> </util:map>  <bean id="parentaction" class="my.package.parentaction" scope="prototype">     <property name="businessdelegate" ref="businessdelegatenotrelevanttothisexample" /> </bean>  <bean id="childaction" class="my.package.childaction" scope="prototype" parent="parentaction">     <property name="typetourlmap" ref="typetourlmap"/> </bean> 

for reason, setter being called on parent action, not in child action. is there wrong configuration?

note: understanding util:map default java type of hashmap.

my parentaction looks following:

 public class parentaction extends myappbaseaction {          private businessdelegate businessdelegate;          //other action code using business delegate          /**          *  called.         */         public void setbusinessdelegate(businessdelegate delegate){             this.businessdelegate = delegate;         }     } 

my childaction looks following:

public class childaction extends parentaction{      private map<string,string> typetourlmap;      //other action code using map      /**      *  never called! (why?)     */     public void settypetourlmap(map<string,string map){         this.typetourlmap = map;     } } 

any appreciated. thanks!

try writing unit test applicationcontext.xml file

public class applicationcontexttest extends testcase {    protected applicationcontext      ctx;    protected static final string[]   context_locations = new string[] {       "classpath:resources/applicationcontext.xml"};    public void setup() throws exception {     super.setup();     ctx = new classpathxmlapplicationcontext(context_locations);   }    public void test() {     childaction ca = ctx.getbean("childaction", childaction.class);     assertnotnull(ca.gettypetourlmap());   } } 

if test passes @ how struts integrated spring


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -