I was running a simple example, which worked, but am confused by something. It injects a string value into a simple class:
/**
* Created on Sep 21, 2011
*/
package com.apress.prospring3.ch4;
/**
* @author Clarence
*
*/
public class SimpleTarget {
private String val;
public void setVal(String val) {
this.val = val;
}
public String getVal() {
return val;
}
}
The xml that injects the string value is:
<bean id="injectBean" class="java.lang.String">
<constructor-arg>
<value>Bean In Child</value>
</constructor-arg>
</bean>
My question is since the class defines no constructor method with a string variable, but defines a setter function with a String variable, why does this work? I would think setter notation in the xml would be used.
Thanks


Reply With Quote