SSH---整合案例----在web程序中加入spring(1)

1.加入spring
    1.1 加入jar包
    1.2 配置web.xml文件(使用原理及具体步骤也就是说,使用了ContextLoaderListener之后,自动创建IOC容器并且把IOC容器

                                                                          以Application属性的方式放在了Application的域对象中,直接调用就可以)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
</web-app>

1.3 加入spring的配置文件 (applicationContext.xml此时可以为空什么都不用写)

猜你喜欢

转载自blog.csdn.net/lsh15846393847/article/details/89517064