如何搭建struts2.0+spring2.x+hibernate3.doc
文本预览下载声明
创建工程:
为工程添加spring 支持
为工程添加hibernate支持
把hibernate配置信息加入到已存在的spring 配置文件中
选择已存在的spring 配置文件:
选择数据库连接(点击finish):
当点击“finish”,会提示包之间有冲突选择“replace”
加入struts2.0 包,以下2.0 的包是必须的:
9.删除工程中以下选中的包:
在工程中加入连接数据库的包,在Eclipse 安装目录中查找一个commons-pool.jar 文件。如果有多个commons-pool.jar ,任意拷贝一个jar 文件加入到工程中。
在工程中修改web.xml 文件:
Web.xml修改后的代码如下:
?xml version=1.0 encoding=UTF-8?
web-app version=2.5 xmlns=/xml/ns/javaee
xmlns:xsi=/2001/XMLSchema-instance
xsi:schemaLocation=/xml/ns/javaee
/xml/ns/javaee/web-app_2_5.xsd
context-param
param-namecontextConfigLocation/param-name
param-valueclasspath:applicationContext.xml
/param-value
/context-param
listener
listener-class
org.springframework.web.context.ContextLoaderListener
/listener-class
/listener
filter
filter-namestruts2/filter-name
filter-class
org.apache.struts2.dispatcher.FilterDispatcher
/filter-class
/filter
filter-mapping
filter-namestruts2/filter-name
url-pattern/*/url-pattern
/filter-mapping
welcome-file-list
welcome-fileindex.jsp/welcome-file
/welcome-file-list
/web-app
在工程的src 目录下增加 struts.xml 和 perties 文件:
struts.xml 文件代码如下:
?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE struts PUBLIC
-//Apache Software Foundation//DTD Struts Configuration 2.0//EN
/dtds/struts-2.0.dtd
struts
/struts
perties 文件代码如下:
struts.locale=zh_CN
struts.i18n.encoding=GB2312
struts.objectFactory = spring
struts.objectFactory.spring.autoWire = name
显示全部