<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0060)http://www.360doc.com/content/09/0416/09/61497_3148602.shtml -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Struts2与Spring、Hibernate三者整合的过程示例</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8" ;>
<META content=360doc name=classification>
<META content=struts2.0,Struts2,Hibernate,spring,SSH name=keywords>
<META content=Struts2与Spring、Hibernate三者整合的过程示例 name=description>
<META content=www.360doc.com name=author><LINK
href="Struts2与Spring、Hibernate三者整合的过程示例.files/StickySystemIEBlue.css"
type=text/css rel=stylesheet>
<SCRIPT>
window.onerror = ignoreError;
function ignoreError()
{
return true;
}
google_ad_client = "pub-6625678643128649";
google_alternate_color = "FFFFFF";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="";
</SCRIPT>
<META content="MSHTML 6.00.2900.3640" name=GENERATOR></HEAD>
<BODY onmouseup=setDragEnd() onmousemove=DragDiv(); onclick=delAllDiv(event)>
<DIV class=top2>
<DIV class=top_con>
<DIV class=logo02><IMG alt=360doc
src="Struts2与Spring、Hibernate三者整合的过程示例.files/logo02.gif"></DIV>
<DIV class=nav_3>
<DIV class=ad01 id=ad01></DIV><SPAN class="nav_2_tit02 link_underline"><A
href="http://www.360doc.com/help.aspx" target=_blank>帮助</A> | <A
href="http://www.360doc.com/advice.aspx" target=_blank>留言交流</A> |
<SPAN id=loginstatus></SPAN></SPAN></DIV>
<DIV class=navcg1>
<DIV class=search_mokuaicg1>
<DIV class=mokuai_navcg1><SPAN class="uncleckedcg1 link_blackcg1"><A
href="http://www.360doc.com/index.aspx">首页</A></SPAN> <SPAN
class="unclecked link_black"><A
href="http://www.360doc.com/myfiles.aspx">我的图书馆</A></SPAN> <SPAN
class="unclecked link_black"><A
href="http://www.360doc.com/topic.aspx">主题阅读</A></SPAN> <SPAN
class="uncleckedcg1 link_blackcg1"><A
href="http://www.360doc.com/catalog.aspx">精彩目录</A></SPAN> <SPAN
class="uncleckedcg1 link_blackcg1"><A
href="http://www.360doc.com/forumfocus.aspx">精品文苑</A></SPAN> <SPAN
class="uncleckedcg1 link_blackcg1"><A
href="http://www.360doc.com/tags.aspx">Tags</A></SPAN> <SPAN
class="uncleckedcg1 link_blackcg1"><A
href="http://www.360doc.com/showusers.aspx">会员浏览</A></SPAN> <SPAN
class="uncleckedcg1 link_blackcg1"><A
href="http://www.360doc.com/Books.aspx"><SPAN
style="FONT-SIZE: 11px">好书推荐</SPAN></A></SPAN> </DIV>
<DIV class=mokuai_concg1>
<DIV id=a_ul_0 style="DISPLAY: none"></DIV>
<DIV id=a_ul_1 style="DISPLAY: none"></DIV>
<DIV id=a_ul_2 style="DISPLAY: none"></DIV>
<DIV id=a_ul_3 style="DISPLAY: none"></DIV>
<DIV id=a_ul_4 style="DISPLAY: none"></DIV>
<DIV id=a_ul_5 style="DISPLAY: none"></DIV>
<DIV id=a_ul_6 style="DISPLAY: none"></DIV></DIV></DIV></DIV></DIV></DIV>
<DIV class=index_main>
<DIV class=wenzhang_tit>Struts2与Spring、Hibernate三者整合的过程示例(转载)</DIV>
<DIV class="wenzhang_ft link_underline">
<TABLE>
<TBODY>
<TR>
<TD><SPAN class=link_green><A
href="http://www.360doc.com/UserHome/61497.aspx"
target=_blank>pengx</A></SPAN> 收录于2009-04-16 阅读数:<SPAN
id=360doc_Readnum></SPAN></TD>
<TD>
<DIV id=360doc_saverNum></DIV></TD>
<TD>
<DIV id=360doc_artpermission>公众公开 </DIV></TD>
<TD vAlign=bottom><SPAN class=link_underlinecg><A
href="http://hi.baidu.com/candyСÆð/blog/item/974f8e09a1901738e8248876.html"
target=_blank>原文来源</A> </SPAN> </TD></TR></TBODY></TABLE></DIV>
<DIV class="wenzhang_ft tags"><STRONG>tags: </STRONG><A
href="http://www.360doc.com/tagarticle.aspx?tag=struts2.0"
target=_blank>struts2.0</A> <A
href="http://www.360doc.com/tagarticle.aspx?tag=Struts2"
target=_blank>Struts2</A> <A
href="http://www.360doc.com/tagarticle.aspx?tag=Hibernate"
target=_blank>Hibernate</A> <A
href="http://www.360doc.com/tagarticle.aspx?tag=spring" target=_blank>spring</A>
<A href="http://www.360doc.com/tagarticle.aspx?tag=SSH" target=_blank>SSH</A>
</DIV>
<DIV id=360docIsStrangerUp></DIV>
<DIV class=wenzhang_cz>
<TABLE width="100%">
<TBODY>
<TR>
<TD vAlign=top align=left>
<DIV id=headFirst></DIV></TD>
<TD vAlign=top align=right>
<DIV id=headSecond style="FLOAT: right"></DIV></TD></TR></TBODY></TABLE></DIV>
<TABLE class=index_main cellSpacing=1 cellPadding=1 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=left width=740>
<DIV id=clickeye_content>
<TABLE>
<TBODY>
<TR>
<TD style="WIDTH: 740px" vAlign=top><SPAN
onmouseup=NewHighlight(event) class=wenzhang_con id=articlecontent
style="WIDTH: 740px">
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV>
<P
align=left><STRONG>Struts2</STRONG>与<STRONG>Spring</STRONG>、<STRONG>Hibernate</STRONG>三者整合的过程示例:</P>
<P align=left>示例工具:<STRONG>MyEclipse 7.0</STRONG>、<STRONG>Tomcat
6.0</STRONG>、<STRONG>MySql</STRONG></P>
<P align=left>步骤:</P>
<P align=left>1.创建一个WEB工程,命名为BookShop(名字自己取,此处为示例工程名);</P>
<P
align=left>2.导入struts2的核心jar包,也就是在WEB-INF下的lib文件夹中放入jar包文件,如下图(图中jar包为示例版本):</P>
<DIV forimg="1">
<P><IMG height=120
src="Struts2与Spring、Hibernate三者整合的过程示例.files/20090416095734460.jpg"
width=234 border=0></P>
<P>3.加载spring,选中工程名,右击并选择【MyEclipse】选项下的【Add Spring
Capabilities...】(或者在工具栏中选择【MyEclipse】下的【Add Spring
Capabilities...】),在弹出的对话框中进行如下图所示操作:</P></DIV>
<DIV forimg="1">
<DIV forimg="1">
<P> <IMG height=480
src="Struts2与Spring、Hibernate三者整合的过程示例.files/20090416095752266.jpg"
width=426 border=0></P>
<P>点击【Next】,点击Folder文本框后的【Browse】,在弹出对话框中选择spring配置文件存储位置为WEB-INF文件夹,如下图所示:</P>
<P forimg="1"></P>
<DIV forimg="1"><IMG height=406
src="Struts2与Spring、Hibernate三者整合的过程示例.files/20090416095809660.jpg"
width=411
border=0><BR>点击【OK】后,再点击【Finish】完成。至此,已经完成加载spring,在WEB-INF文件夹下已经生成了配置文件applicationContext.xml。</DIV>
<P forimg="1">4.加载Hibernate,选择【MyEclipse】下的【Add Hibernate
Capabilities...】,在弹出对话框中进行如下图所示操作: </P>
<DIV forimg="1"></DIV>
<DIV forimg="1"><IMG height=480
src="Struts2与Spring、Hibernate三者整合的过程示例.files/20090416095825132.jpg"
width=491 border=0><BR>点击【Next】后,选择Existing Spring configuration
file单选框,在SessionFactory Id文本框中填入"sessionFactory",如下图所示 :</DIV>
<P forimg="1"></P>
<DIV forimg="1"><IMG height=480
src="Struts2与Spring、Hibernate三者整合的过程示例.files/20090416095838419.jpg"
width=569 border=0><BR>点击【Next】�