1、web.xml设置监听
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:SpringConfig*.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2、在springconfig.xml中设置自动需要扫描的包
<context:component-scan base-package="com.jmd" />
3、在需要加载成bean的地方 使用注解方式
@Controller通知spring进行默认加载。