spring-210724-04–IOC容器–Bean管理XML方式-注入空值和特殊符号
beantest21072401.xml(笔记在注释中哦)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="book01" class="com.bgy.spring.Book">
<property name="bname">
<null/>
</property>
<property name="bauthor">
<null/>
</property>
</bean>
<bean id="book02" class="com.bgy.spring.Book">
<property name="bname">
<null/>
</property>
<property name="bauthor">
<value>
<![CDATA[<hhhhhhh>]]>
</value>
</property>
</bean>
</beans>
TestBean21072401.java
import com.bgy.spring.Book;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestBean21072401 {
@Test
public void test01(){
ApplicationContext context = new ClassPathXmlApplicationContext("beantest21072401.xml");
Book book = context.getBean("book01", Book.class);
book.test();
}
@Test
public void test02(){
ApplicationContext context = new ClassPathXmlApplicationContext("beantest21072401.xml");
Book book = context.getBean("book02", Book.class);
book.test();
}
}