📄 blogjava - oksonic博客 - struts+spring+hibernate练习(完整).mht
字号:
<DIV> </DIV>
<DIV>import org.apache.struts.action.Action;<BR>import=20
org.apache.struts.action.ActionForm;<BR>import=20
org.apache.struts.action.ActionForward;<BR>import=20
org.apache.struts.action.ActionMapping;<BR>import=20
org.apache.struts.validator.DynaValidatorForm;</DIV>
<DIV> </DIV>
<DIV><FONT color=3D#008000>import =
com.test.UserDAO;</FONT></DIV>
<DIV><BR>public class LoginAction extends Action {</DIV>
<DIV><BR> <FONT color=3D#008000>private UserDAO=20
userDAO</FONT>;</DIV>
<DIV> </DIV>
<DIV><FONT color=3D#008000> public UserDAO getUserDAO() =
{<BR> return userDAO;<BR> }</FONT></DIV>
<DIV><FONT color=3D#008000></FONT> </DIV>
<DIV><FONT color=3D#008000> public void =
setUserDAO(UserDAO=20
userDAO) {<BR> this.userDAO =3D=20
userDAO;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV> public ActionForward execute(ActionMapping =
mapping,=20
ActionForm form,<BR> HttpServletRequest =
request,=20
HttpServletResponse response) =
{<BR> DynaValidatorForm=20
loginForm =3D (DynaValidatorForm) form;<BR> // =
TODO=20
Auto-generated method stub<BR> String username =
=3D (String)=20
loginForm.get("username");<BR> String password =
=3D (String)=20
=
loginForm.get("password");<BR> loginForm.set("password",=20
null);<BR> <FONT color=3D#008000>if=20
(userDAO.isValidUser(username,password))=20
{<BR> return=20
mapping.findForward("indexGo");<BR> } else=20
{<BR> return=20
=
mapping.getInputForward();<BR> }<BR></FONT> }</DIV>
=
<DIV>}<BR>=E7=BB=BF=E8=89=B2=E5=AD=97=E4=BD=93=E4=B8=BA=E4=BF=AE=E6=94=B9=
=E9=83=A8=E4=BB=BD</DIV>
<DIV> </DIV>
=
<DIV>=E7=8E=B0=E5=9C=A8=E5=89=A9=E4=B8=8B=E6=9C=80=E5=90=8E=E7=9A=84sprin=
g=E9=85=8D=E7=BD=AE=E4=BA=86</DIV>
<DIV><?xml version=3D"1.0" =
encoding=3D"UTF-8"?><BR><!DOCTYPE=20
beans PUBLIC "-//SPRING//DTD BEAN//EN" "<A=20
=
href=3D"http://www.springframework.org/dtd/spring-beans.dtd"><FONT=20
=
color=3D#8d8c8c>http://www.springframework.org/dtd/spring-beans.dtd</FONT=
></A>"></DIV>
<DIV> </DIV>
<DIV><beans><BR> <bean id=3D"dataSource"=20
class=3D"org.apache.commons.dbcp.BasicDataSource"=20
destroy-method=3D"close"><BR> <property=20
=
name=3D"driverClassName"><BR> <value>com.mysql.=
jdbc.Driver</value><BR> </property><BR>  =
;<property=20
=
name=3D"url"><BR> <value>jdbc:mysql://localhost=
/test</value><BR> </property><BR> <p=
roperty=20
=
name=3D"username"><BR> <value>root</value>=
;<BR> </property><BR> <property=20
=
name=3D"password"><BR> <value>root</value>=
;<BR> </property><BR> </bean></DIV>
<DIV> </DIV>
<DIV> <!-- =E9=85=8D=E7=BD=AEsessionFactory, =
=E6=B3=A8=E6=84=8F=E8=BF=99=E9=87=8C=E5=BC=95=E5=85=A5=E7=9A=84=E5=8C=85=E7=
=9A=84=E4=B8=8D=E5=90=8C =20
--><BR> <bean id=3D"sessionFactory"=20
=
class=3D"org.springframework.orm.hibernate3.LocalSessionFactoryBean"><=
BR> <property=20
name=3D"dataSource"><BR> <ref=20
local=3D"dataSource"=20
=
/><BR> </property><BR> <property=20
=
name=3D"mappingResources"><BR> <list><BR> =
<value>com/test/Hibernate/User.hbm.xml</value&=
gt;<BR> </list><BR> </property><B=
R> <property=20
=
name=3D"hibernateProperties"><BR> <props><BR>&n=
bsp; <prop=20
=
key=3D"hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop&=
gt;<BR> <prop=20
=
key=3D"hibernate.show_sql">true</prop><BR> <=
/props><BR> </property><BR> </bean></DIV>
<DIV> </DIV>
<DIV> <bean id=3D"transactionManager"=20
=
class=3D"org.springframework.orm.hibernate3.HibernateTransactionManager"&=
gt;<BR> <property=20
name=3D"sessionFactory"><BR> <ref=20
local=3D"sessionFactory"=20
=
/><BR> </property><BR> </bean></DIV>
<DIV> </DIV>
<DIV> <bean id=3D"userDAO"=20
=
class=3D"com.test.UserDAOImp"><BR> <property=20
name=3D"sessionFactory"><BR> <ref=20
local=3D"sessionFactory"=20
=
/><BR> </property><BR> </bean></DIV>
<DIV> </DIV>
<DIV> <bean id=3D"userDAOProxy"=20
=
class=3D"org.springframework.transaction.interceptor.TransactionProxyFact=
oryBean"><BR> <property=20
name=3D"transactionManager"><BR> <ref =
bean=3D"transactionManager"=20
=
/><BR> </property><BR> <property=20
name=3D"target"><BR> <ref =
local=3D"userDAO"=20
=
/><BR> </property><BR> <property=20
=
name=3D"transactionAttributes"><BR> <props><BR>=
<prop=20
=
key=3D"insert*">PROPAGATION_REQUIRED</prop><BR>  =
; <prop=20
=
key=3D"get*">PROPAGATION_REQUIRED,readOnly</prop><BR>  =
; <prop=20
=
key=3D"is*">PROPAGATION_REQUIRED,readOnly</prop><BR> =
</props><BR> </property><BR> </bean&=
gt;</DIV>
<DIV> </DIV>
<DIV> <bean name=3D"/login"=20
class=3D"com.test.struts.action.LoginAction"=20
singleton=3D"false"><BR> <property=20
name=3D"userDAO"><BR> <ref =
bean=3D"userDAOProxy"=20
=
/><BR> </property><BR> </bean><BR></bea=
ns></DIV>
<DIV> </DIV>
=
<DIV>=E7=8E=B0=E5=9C=A8=E5=8F=AF=E4=BB=A5=E8=BF=9B=E8=A1=8C=E6=B5=8B=E8=AF=
=95=E4=BA=86=EF=BC=81</DIV>
<DIV> </DIV>
=
<DIV>=E5=9C=A8=E7=BC=96=E5=86=99=E4=BB=A3=E7=A0=81=E6=9C=89=E9=85=8D=E7=BD=
=AE=E5=86=85=E5=AE=B9=E6=97=B6=E4=B8=80=E5=AE=9A=E8=A6=81=E6=B3=A8=E6=84=8F=
hibernate =E5=92=8C hibernate3=20
=
=EF=BC=8C=E8=BF=99=E4=B8=A4=E4=B8=AA=E5=8C=85=E7=9A=84=E5=90=8D=E5=AD=97=E5=
=B0=B1=E5=8F=AA=E5=B7=AE=E4=B8=80=E4=B8=AA=E5=AD=97=EF=BC=8C=E5=8D=83=E4=B8=
=87=E4=B8=8D=E8=A6=81=E6=9C=89=E9=94=99=EF=BC=8C=E5=90=A6=E5=88=99=E6=89=BE=
=E9=94=99=E8=AF=AF=E5=8F=AF=E6=98=AF=E5=BE=88=E9=9A=BE=E7=9A=84=E3=80=82<=
/DIV></DIV></DIV></DIV></DIV>
<DIV class=3Ditemdesc>=E5=8F=91=E8=A1=A8=E4=BA=8E 2005-11-06 =
11:04 <A=20
href=3D"http://www.blogjava.net/oksonic/">oksonic</A> =
=E9=98=85=E8=AF=BB(3268) <A=20
=
href=3D"http://www.blogjava.net/oksonic/archive/2005/11/06/18370.html#Pos=
t">=E8=AF=84=E8=AE=BA(28)</A>=20
<A=20
=
href=3D"http://www.blogjava.net/oksonic/admin/EditPosts.aspx?postid=3D183=
70">=E7=BC=96=E8=BE=91</A> <A=20
=
href=3D"http://www.blogjava.net/oksonic/AddToFavorite.aspx?id=3D18370">=E6=
=94=B6=E8=97=8F</A>=20
<A =
title=3D=E5=8A=9F=E8=83=BD=E5=BC=BA=E5=A4=A7=E7=9A=84=E7=BD=91=E7=BB=9C=E6=
=94=B6=E8=97=8F=E5=A4=B9=EF=BC=8C=E4=B8=80=E7=A7=92=E9=92=9F=E6=93=8D=E4=BD=
=9C=E5=B0=B1=E5=8F=AF=E4=BB=A5=E8=BD=BB=E6=9D=BE=E5=AE=9E=E7=8E=B0=E4=BF=9D=
=E5=AD=98=E5=B8=A6=E6=9D=A5=E7=9A=84=E4=BB=B7=E5=80=BC=E3=80=81=E5=88=86=E4=
=BA=AB=E5=B8=A6=E6=9D=A5=E7=9A=84=E5=BF=AB=E4=B9=90=20
=
href=3D"javascript:d=3Ddocument;t=3Dd.selection?(d.selection.type!=3D'Non=
e'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():''=
);void(keyit=3Dwindow.open('http://www.365key.com/storeit.aspx?t=3D'+esca=
pe(d.title)+'&u=3D'+escape(d.location.href)+'&c=3D'+escape(t),'ke=
yit','scrollbars=3Dno,width=3D475,height=3D575,left=3D75,top=3D20,status=3D=
no,resizable=3Dyes'));keyit.focus();">=E6=94=B6=E8=97=8F=E8=87=B3365Key</=
A>=20
=E6=89=80=E5=B1=9E=E5=88=86=E7=B1=BB: <A=20
=
href=3D"http://www.blogjava.net/oksonic/category/5896.html">java</A>=20
</DIV></DIV>
<DIV class=3Dseperator> </DIV><IMG height=3D1=20
=
src=3D"http://www.blogjava.net/oksonic/aggbug/18370.html?webview=3D1"=20
width=3D1> <!--
<rdf:RDF xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc=3D"http://purl.org/dc/elements/1.1/"=0A=
xmlns:trackback=3D"http://madskills.com/public/xml/rss/module/trackback/"=
>
<rdf:Description
rdf:about=3D"http://www.blogjava.net/oksonic/archive/2005/11/06/18370.htm=
l"
dc:identifier=3D"http://www.blogjava.net/oksonic/archive/2005/11/06/18370=
.html"
dc:title=3D"Struts+Spring+Hibernate=E7=BB=83=E4=B9=A0(=E5=AE=8C=E6=95=B4)=
"
trackback:ping=3D"http://www.blogjava.net/oksonic/services/trackbacks/183=
70.aspx" />
</rdf:RDF>
-->
<DIV class=3Dpost><A name=3D=E8=AF=84=E8=AE=BA>
<DIV class=3Dmoreinfo>
<DIV class=3Dmoreinfotitle>=E8=AF=84=E8=AE=BA </DIV>
<DIV class=3Dcomments>
<DIV class=3Dcomment>
<DIV class=3Dcomment_title><A=20
title=3D"permalink: re: =
Struts+Spring+Hibernate=E7=BB=83=E4=B9=A0(=E5=AE=8C=E6=95=B4)"=20
=
href=3D"http://www.blogjava.net/oksonic/archive/2005/11/06/18370.html#224=
40">#</A> <A=20
name=3D22440></A>re: =
Struts+Spring+Hibernate=E7=BB=83=E4=B9=A0(=E5=AE=8C=E6=95=B4) =
<A=20
id=3DComments1_CommentList__ctl1_DeleteLink=20
=
href=3D"javascript:__doPostBack('Comments1$CommentList$_ctl1$DeleteLink',=
'')"></A> <A=20
id=3DComments1_CommentList__ctl1_EditLink></A> </DIV>
<DIV =
class=3Dcomment_content>=E5=86=99=E7=9A=84=E5=BE=88=E8=AF=A6=E7=BB=86=EF=BC=
=8C=E6=94=B6=E8=97=8F=E5=86=8D=E7=A0=94=E7=A9=B6=EF=BC=81</DIV>
<DIV class=3Dcomment_footer><A =
id=3DComments1_CommentList__ctl1_NameLink=20
href=3D"http://www.blueclassic.net/" =
target=3D_blank>airblue</A> =E8=AF=84=E8=AE=BA=E4=BA=8E=20
2005-12-04 15:00</DIV></DIV>
<DIV class=3Dcomment>
<DIV class=3Dcomment_title><A=20
title=3D"permalink: re: =
Struts+Spring+Hibernate=E7=BB=83=E4=B9=A0(=E5=AE=8C=E6=95=B4)"=20
=
href=3D"http://www.blogjava.net/oksonic/archive/2005/11/06/18370.html#231=
26">#</A> <A=20
name=3D23126></A>re: =
Struts+Spring+Hibernate=E7=BB=83=E4=B9=A0(=E5=AE=8C=E6=95=B4) =
<A=20
id=3DComments1_CommentList__ctl2_DeleteLink=20
=
href=3D"javascript:__doPostBack('Comments1$CommentList$_ctl2$DeleteLink',=
'')"></A> <A=20
id=3DComments1_CommentList__ctl2_EditLink></A> </DIV>
<DIV =
class=3Dcomment_content>=E6=A5=BC=E4=B8=BB,=E8=AF=95=E4=BA=86=E4=B8=80=E4=
=B8=8B =
<BR>=E6=80=8E=E4=B9=88=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0action?=E6=8A=A5=
=E9=94=99:The requested=20
resource (Servlet action is not available) is not =
available.</DIV>
<DIV class=3Dcomment_footer><A =
id=3DComments1_CommentList__ctl2_NameLink=20
target=3D_blank>newer for spring</A> =
=E8=AF=84=E8=AE=BA=E4=BA=8E 2005-12-09 13:27</DIV></DIV>
<DIV class=3Dcomment>
<DIV class=3Dcomment_title><A=20
title=3D"permalink: re: =
Struts+Spring+Hibernate=E7=BB=83=E4=B9=A0(=E5=AE=8C=E6=95=B4)"=20
=
href=3D"http://www.blogjava.net/oksonic/archive/2005/11/06/18370.html#231=
59">#</A> <A=20
name=3D23159></A>re: =
Struts+Spring+Hibernate=E7=BB=83=E4=B9=A0(=E5=AE=8C=E6=95=B4) =
<A=20
id=3DComments1_CommentList__ctl3_DeleteLink=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -