Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java程序分享区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
作者 (Hibernate+struts)用hibernate的javabean还是struts的ActionForm?
struggle

不换头像了

CJSDN高级会员


发贴: 330
于 2004-11-30 12:01 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我在项目中想用hibernate+struts来做,hiberante中有一个javabean(set×××、get×××),struts中有一个ActionForm也是做类似事情的,那么我到底要用哪一个呢?

有一网友给我这样解答的:
代码虽然基本一样,但用途不一样,actionForm是对表单数据的封装,它只能在表单和控制器之间进行传输;而hibernate的叫pojo是持久化对象,也就是说是被hibernate存到数据库中的,是由hibernate来维护的,它只能在业务对象和数据操作类之间传输

但来他又说用其中一个也可以,所以我就很迷糊了,按照这位仁兄的说法,在项目中必需两者(ActionForm和hibernate的javabean)都用,因为这两者的使用范围不一样。
那么到底是两者必须用,还是用一者即可呢?怎样用好处多呢?
诚请解答,谢谢!



作者 Re:(Hibernate+struts)用hibernate的javabean还是struts的ActionForm? [Re:struggle]
wes109

以梦为马

CJSDN高级会员


发贴: 857
于 2004-11-30 13:07 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我的想法是,都用

ActionForm 用在表示层,这个是用来处理页面的表单的,不要传到其它地方去

还有一种对象就是domain object,参考spring sample里面的jpetstore的例子。




作者 Re:(Hibernate+struts)用hibernate的javabean还是struts的ActionForm? [Re:struggle]
struggle

不换头像了

CJSDN高级会员


发贴: 330
于 2004-11-30 13:54 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
谢谢 wes109 !


作者 Re:(Hibernate+struts)用hibernate的javabean还是struts的ActionForm? [Re:struggle]
mfc42d





发贴: 116
于 2004-12-09 10:20 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
偶不明白,struts的分层并不是很好的,就是很难完全将表示层和逻辑层分开的,不如spring,请wes109指教



reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923