您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 市场营销 > 93《Java程序设计》04 第四天 下午 SSH
Struts+Hibernate+SpringStruts+Hibernate+SpringWebStruts+Hibernate+SpringjavaStrutsHibernateSpringWebStruts+Hibernate+SpringC/SB/SB/S(UILayer/PresentationLayer)strutsBusinessLayerspringPersistenceLayerhibernateStruts+Hibernate+SpringStrutsMVCStruts+Hibernate+SpringStrutsMVCStrutsStrutsStrutsStruts+Hibernate+SpringServletServletServletServletServletJavaBeansJavaBeanjavaJavaBeanJavaBeanJavaBeanBean(getters)JavaBean–getbooleanis(setters)JavaBean–setvoidStruts+Hibernate+SpringStrutsStrutsWebStrutsM2MVC-Model-View-ControllerStruts+Hibernate+SpringModel1Model2JSPModel1JSP+JAVABEANHTMLJAVAJSPMVCMVCStruts+Hibernate+SpringModel2Struts+Hibernate+SpringStrutsStruts+Hibernate+SpringStrutswebHTTPrequestresponsestrutsservlet,struts-config.xmlstrutsActionActionFormJSPStruts+Hibernate+SpringStrutsActionServletActionServletURIAction,Action,Action,ActionServletURIActionForm,ActionAction,ActionForward,ActionServletActionForwardStrutsActionMapping,ActionMappingURI,,ActionServletActionMappingActionMappingActionServletActionActionFormActionForwardActionActionFormActionForwardStrutsstruts-config.xmlStruts+Hibernate+SpringStruts1.XStruts2.XStruts1.XStruts2.XStruts1.XStruts2.XWebworkwebwork/Struts2.XStruts+Hibernate+SpringStrutsadmin1EclipseJ2EEWeb2Struts*Apachestruts*STRUTS_HOME3STRUTS_HOME/lib.jarwebWebContent/WEB-INF/lib4ActionServlet:webweb.xmlServletStruts+Hibernate+Springweb.xmlservletservlet-nameaction/servlet-nameservlet-classorg.apache.struts.action.ActionServlet/servlet-classinit-paramparam-nameconfig/param-nameparam-value/WEB-INF/struts-config.xml/param-value/init-paramload-on-startup2/load-on-startup/servletservlet-mappingservlet-nameaction/servlet-nameurl-pattern*.do/url-pattern/servlet-mappingStruts+Hibernate+SpringActionForm–LoginActionForm.javaAction–LoginAction.javastruts-config.xml–login.jsp–login_success.jsp–login_error.jspStruts+Hibernate+SpringLoginActionForm.javaActionFormJavaBeanorg.apache.struts.action.ActionFormHTTPActionFormHTMLActionServletActionFormActionFormsetterActionFormlogin.jspusernamepasswordActionFormsettersetUsernamesetPasswordActionFormgetter/setterEclipseActionFormprivate(public)getter/setterpackagecom.bjsxt.strutstest;importorg.apache.struts.action.ActionForm;publicclassLoginActionFormextendsActionForm{privateStringusername;privateStringpassword;/***@returnReturnsthepassword.*/publicStringgetPassword(){returnpassword;}/***@parampasswordThepasswordtoset.*/publicvoidsetPassword(Stringpassword){this.password=password;}/***@returnReturnstheusername.*/publicStringgetUsername(){returnusername;}/***@paramusernameTheusernametoset.*/publicvoidsetUsername(Stringusername){this.username=username;}}Struts+Hibernate+SpringLoginAction.javaActionJavaorg.apache.struts.action.ActionActionServletActionFormActionActionActionForwardLoginActionActionActionFormLoginActionFormLoginActionFormActionForwardsuccesserrorpublicclassLoginActionextendsAction{publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse)throwsException{//ActionFormLoginActionFormLoginActionFormloginForm=(LoginActionForm)form;//LoginActionFormStringusername=loginForm.getUsername();Stringpassword=loginForm.getPassword();//if(admin.equals(username)&&admin.equals(password)){//adminreturnmapping.findForward(success);}else{//returnmapping.findForward(error);}}}Struts+Hibernate+SpringStrutsstruts-config.xmlWebContent/WEB-INFstruts-config.xmlstruts-config.xml,?xmlversion=1.0encoding=ISO-8859-1?!DOCTYPEstruts-configPUBLIC-//ApacheSoftwareFoundation//DTDStrutsConfiguration1.2//ENstruts-config.xmlActionServletActionActionFormActionForwardStruts+Hibernate+SpringActionFormLoginActionFormstruts-config.xmlstruts-configform-beansform-beanname=loginFormtype=com.bjsxt.strutstest.LoginActionForm//form-beansform-beansform-beanform-beannametypenameActionFormtypeActionFormStruts+Hibernate+SpringActionLoginActionstruts-config.xmlform-beansLoginActionactionpath-URLAction.dotype–URLActionActionname–ActionFormscope–FormBeansessionrequestrequestaction-mappingsactionpath=/login“type=com.bjsxt.strutstest.LoginAction“name=loginForm“scope=“request”forwardname=successpath=/login_success.jsp/forwardname=errorpath=/login_error.jsp//action/action-mappingsStruts+Hibernate+Springlogin.jspWebContentlogin.jspactionlogin.dologin.dostrutsActionServletActionusernameusernameLoginActionFormpassword%@pagelanguage=javacontentType=text/html;charset=GB18030pageEncoding=GB18030%!DOCTYPEHTMLPUBLIC-//W3C//DTDHTML4.01Transitional//ENhtmlheadmetahttp-equiv=Content-Typecontent=text/html;charset=GB18030title/title/headbodyformaction=login.domethod=postinputtype=textname=usernamebr/inputtype=passwordname=passwordbr/inputtype=submitname=submit1value=/form
本文标题:93《Java程序设计》04 第四天 下午 SSH
链接地址:https://www.777doc.com/doc-6432875 .html