ssm框架学习之(二) --srping3集成
现在spring 3集成
1 首先加入spring3所需要的包,在之前的struts包中有包含
spring-asm-3.0.5.RELEASE.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-core-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar
struts2-spring-plugin-2.3.4.1.jar
2 web.xml 增加如入配置
<!-- spring监听器 --><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!-- spring监听器,使用scrope=request 时必须加上 --><listener><listener-class>org.springframework.web.context.request.RequestContextListener</listener-class></listener><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:/config/applicationContext-beans.xml</param-value></context-param>
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"><!-- 注解探测器 --><context:component-scan base-package="com.rabbit.demo.*" /></beans>
@Override public List<Bonus> browse() {// TODO Auto-generated method stubSystem.out.println("come here");return null; }