There are three methods:
- Normal way
- Shortcut
- "P" Schema
Suppose we have such a bean:
Public class filenamegenerator {private string name; private string type; Public String getname () {return name;} public void setname (string name) {This. name = Name;} Public String GetType () {return type;} public void settype (string type) {This. type = type ;}}
1. normal way
<Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id = "filenamegenerator" class = "com. mkyong. common. filenamegenerator "> <property name =" name "> <value> mkyong </value> </property> <property name =" type "> <value> TXT </value> </property> </bean> </beans>
2. Shortcut
<Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id = "filenamegenerator" class = "com. mkyong. common. filenamegenerator "> <property name =" name "value =" mkyong "/> <property name =" type "value =" TXT "/> </bean> </beans>
3. "P" schema
<Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: P = "http://www.springframework.org/schema/p" xsi: schemalocation = "http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id = "filenamegenerator" class = "com. mkyong. common. filenamegenerator "P: Name =" mkyong "P: TYPE =" TXT "/> </beans>
The third method needs to be added: Xmlns: P = "http://www.springframework.org/schema/p
You can choose either of the three methods, depending on your preferences.