通过配置defalut—autowire属性,Spring IOC容器可以自动为程序注入Bean:默认是no(不启用自动装配). default—autowire的类型有: byName:通过名称自动进行匹配 byType:通过属性自动进行匹配 示例如下: 一个实体类people public class People{ private int id; private String name; private int age; private Dog dog; } beans.xml配置: <?
一.基本支持 通常我们整合Spring和struts2的目的是让Spring来管理struts2的控制器.也就是说把Action交由Spring来管理,利用IOC的特性把Action注入到业务逻辑中. 为此Spring提供了相应的监听器.通过注册 Servlet 监听器 ContextLoaderListener, Web 应用程序可以加载 Spring 的ApplicationContext 对象.这个监听器会将加载好的ApplicationContext 对象保存到 Web 应用程序的 Se
Spring自动装配----注解装配----Spring自带的@Autowired注解 父类 package cn.ychx; public interface Person { public void sayHello(); } 学生子类 package cn.ychx; public class Student implements Person { @Override public void sayHello() { System.out.println("Hello! My name i