突然学这个东西,找了本书来速成。
struts 2.21 spring 2.5.6 用注释方式配置ioc什么的。
1.struts基本配置,另外记得添加struts2-spring-plugin-2.2.1.1.jar这个包
2.spring按文档要求spring.jar、jakarta-commons、log4j,log4j什么的struts加过就别再加了。
3.web.xml中
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:com/ssh/spring/*.xml</param-value>
</context-param>
<!-- 注册spring监听器 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
为的是修改spring配置文件的载入位置,contextConfigLocation是搜索的参数,value放路径
4.spring的配置文件中
<context:component-scan base-package="com.ssh"/>
开启注释支持,com.ssh为支持范围的包名,其下所有子包都可以用注释。
本文介绍如何将Struts2与Spring框架整合,包括所需jar包、web.xml配置及Spring配置文件设置等步骤,帮助读者快速实现基于注释的IoC容器配置。
2050

被折叠的 条评论
为什么被折叠?



