1.Struts2配置,详请见:http://blog.youkuaiyun.com/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 core和Spring 2.0 web。
同时把struts 2.0.11中的struts2-core-2.0.11.1.jar、xwork-2.0.4.jar、commons-logging-1.0.4.jar、freemarker-2.3.8.jar、ognl-2.6.11.jar、struts2-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