- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
SSH框架建
1、创建web应用
2、添加spring支持,选择需要的类库,并选择“JAR Libraries Installation”中第二个选项:Copy checked Library contents to project folder (TLDs always copied),将类库保存到项目的lib目录下。
3、添加Hibernate支持:
4、下一步:选择“Spring Configuration file(applicationContext.xml)“
5、下一步:选择“Existing Spring configuration file”在SessionFactory Id 中填入sessionFactory.
6、下一步:如图填写
7、添加Hibernate实体及其映射文件
8、对Dao类中的方法抽取接口并将接口和实现分包放置,
9、建立biz接口和bizImpl实现类,实现类中添加Dao接口的引用,并添加get/set方法,10、在具体业务方法中调用Dao的方法实现业务逻辑。
11、在applicationContext.xml中配置bizImpl实现类
bean id=accountDAO class=ssh.dao.AccountDAO
property name=sessionFactory
ref bean=sessionFactory /
/property
/bean
bean id=accountBiz class=ssh.biz.impl.AccountBizImpl
property name=dao
ref bean=accountDAO /
/property
property name=allDao
ref bean=allAccountDAO /
/property
/bean
12、添加Struts支持,在struts-config.xml中添加插件元素:
plug-in className=org.springframework.web.struts.ContextLoaderPlugIn
set-property property=contextConfigLocation value=classpath:applicationContext.xml/
/plug-in
13、创建form/Action/Jsp并将struts-config.xml文件中Action的type改为:type=org.springframework.web.struts.DelegatingActionProxy
14、在Action中添加Biz接口的引用,并添加get/set 方法
15、编写要执行的Action方法,调用Biz引用完成业务操作。完成后转入到指定页面。
16、在applicationContext.xml中配置Action:将bean的id改为name=“path“
bean name=/account class=com.ssh.struts.action.AccountAction
property name=accountBiz
ref bean=accountBiz /
/property
/bean
17、编写页面代码,加入方法参数
18、注意需要将库中的sam.2.2.3.jar删除,否则它和sam.jar包冲突,会出现如下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name sessionFactory defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table goods refers to an unmapped class: com.wxn.entity.User
19、配置事务(参见配置模板)
20、部署项目,运行项目。
21、可能的异常:
版本引发的异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name transactionManager defined in file [D:\tools\Tomcat 6.0\webapps\umgoods\WEB-I
原创力文档


文档评论(0)