SpringFramework(2)
来源:互联网 发布:网络兼容模式怎么设置 编辑:程序博客网 时间:2024/05/02 02:38
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
一、Spring基础
1、核心
(1)IoC/Dependency Injection
l IoC/Dependency Injection(依赖注入):Beans不依赖于框架;容器注入依赖
l 轻量级Spring容器:配置和管理Beans
<beans>
<bean id="exampleBean" class="eg.ExampleBean"/>
<bean id="anotherExample" class="eg.ExampleBeanTwo"/>
</beans>
InputStream input = new FileInputStream("beans.xml");
BeanFactory factory = new XmlBeanFactory(input);
ExampleBean eb = (ExampleBean)factory.getBean("exampleBean");
ExampleBeanTwo eb2 = (ExampleBeanTwo)factory.getBean("anotherExample");
可能会抛出NoSuchBeanDefinitionException;
ExampleBean eb = (ExampleBean)factory.getBean("exampleBean", ExampleBean.class);
可能会抛出BeanNotOfRequiredTypeException;
package eg;
public class ExampleBean {
private AnotherBean beanOne;
private YetAnotherBean beanTwo;
public void setBeanOne(AnotherBean b) { beanOne = b; }
public void setBeanTwo(YetAnotherBean b) { beanTwo = b; }
}
<bean id="exampleBean" class="eg.ExampleBean">
<property name="beanOne"><ref bean="anotherExampleBean"/></property>
<property name="beanTwo"><ref bean="yetAnotherBean"/></property>
</bean>
<bean id="anotherExampleBean" class="eg.AnotherBean"/>
<bean id="yetAnotherBean" class="eg.YetAnotherBean"/>
package eg;
public class ExampleBean {
private String s;
private int i;
public void setStringProperty(String s) { this.s = s; }
public void setIntegerProperty(int i) { this.i = i; }
}
<bean id="exampleBean" class="eg.ExampleBean">
<property name="stringProperty"><value>Hi!</value></property>
<property name="integerProperty"><value>1</value></property>
</bean>
<property name="intProperty"><value>7</value></property>
<property name="doubleProperty"><value>0.25</value></property>
<property name="booleanProperty"><value>true</value></property>
<property name="colorProperty"><value>0,255,0</value></property>
<property name="classProperty">
<value>java.lang.Object</value>
</property>
<property name="fileProperty">
<value>/home/ziba/file.txt</value>
</property>
<property name="localeProperty">
<value>pt_BR</value>
</property>
<property name="urlProperty">
<value>http://java.net</value>
</property>
<property name="stringArrayProperty">
<value>foo,bar,baz</value>
</property>
DateFormat fmt = new SimpleDateFormat("d/M/yyyy");
CustomDateEditor dateEditor = new CustomDateEditor(fmt, false);
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- SpringFramework(2)
- SpringFramework(2)
- SpringFramework(2)
- SpringFramework(2)
- SpringFramework(2)
- WebWork2与SpringFramework集成之实例篇(原创)(2)
- SSH Exception 2017.3.23-2 org.springframework.beans.factory.NoSuchBeanDefinitionException
- Crash-fix-2:org.springframework.http.converter.HttpMessageNotReadableException
- Spring学习-(1)SpringFramework官方文档翻译2
- SpringFramework中文论坛
- SpringFrameWork Introduce
- SpringFramework(1)
- SpringFramework(1)
- SpringFramework(1)
- springframework(1)
- SpringFramework(3)
- SpringFramework(4)
- SpringFramework(5)
- log4j使用: 自动设置备份文件
- Tomcat中通过JNDI配置访问数据库
- Java列表对象的性能分析和测试
- servlet生命周期
- 一种基于组件的跨WEB/手机/WINDOS/UNIX平台的多层开发
- SpringFramework(2)
- MSN机器人梦工厂(3)
- 软件过渡开发
- Eclipse使用技巧
- 在STRUTS中如何使用 标签
- log4j的配制及测试程序
- 如何成为一个成功的Jsp程序员?
- 用于较小数的 BigDecimal
- Java读取BMP格式图片(源代码,转)