Struts2整合Spring2.0

来源:互联网 发布:sql insert 多条数据 编辑:程序博客网 时间:2024/05/16 23:39

1.Struts2配置,详请见:http://blog.csdn.net/oyjqdlp364356378/archive/2010/07/06/5715745.aspx

2.Struts2+Spring2.0配置

2.1.准备工作.下载struts-2.0.11包和spring2.0包。

当然Myeclipse中已经有Spring2.0包了,我们将使用Spring 2.0 coreSpring 2.0 web

同时把struts 2.0.11中的struts2-core-2.0.11.1.jarxwork-2.0.4.jarcommons-logging-1.0.4.jarfreemarker-2.3.8.jarognl-2.6.11.jarstruts2-spring-plugin-2.0.11.jar并将这些包拷贝到app/WEB_INF/lib下面

2.2配置web.xml,全部代码如下:

 

2.3配置struts.xml,全部代码如下:

 

 

 

2.4配置applicationContext.xml,在工程目录下的src新建applicationContext.xml文件,并加入以下代码:

 

 

注意:红色标识的<property name="函数名"><ref local="bean名称">,函数名称和bean名称最好是相同的,否则会出现报错的情况,以上配置文件说明,有个ChatAction类,并且有个setService方法,其中参数类型为ChatDaoImpl。以下为ChatAction类的全部代码:

ChatDaoImpl继承IDaoService并实现findAll()方法,具体实际应用,就请各位自动发挥了。。

有什么不懂的地方可以联系:oyjqdlp@126.com

原创粉丝点击