您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > Struts2动态方法调用及通配符的使用
1内蒙古科技大学信息工程学院计算机系《JavaEE程序设计》实验报告姓名王宁学号1267111204实验成绩班级计12-2实验日期第10周(星期五)月日第节项目号、实验名称10Struts2动态方法调用及通配符的实验实验要求项目命名:以自己名字命名。(1)动态方法调用以及method属性测试。(2)通配符的使用及测试。(3)动态结果调用实验内容代码:(1)动态方法调用packageshiyan10;publicclassUser10{privateStringname;privateStringpassword;publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.name=name;}publicStringgetPassword(){returnpassword;}publicvoidsetPassword(Stringpassword){this.password=password;}}packageshiyan10;2publicclassUserAction{User10user;publicUser10getUser(){returnuser;}publicvoidsetUser(User10user){this.user=user;}privatevoidvaildate(){if(getUser().getName().length()==0){addFieldError(name,namecann'tbenull);}if(getUser().getPassword().length()==0){addFieldError(password,passwordcan'tbenull);}}privatevoidaddFieldError(Stringstring,Stringstring2){//TODOAuto-generatedmethodstubSystem.out.println(acount:+string+string2);}publicStringlogin(){if(user.getName().equals(ss)&&user.getPassword().equals(ss)){System.out.println(loginsuccess);returnsuc;}else{System.out.println(loginfail!);returnfail;}}publicStringregister(){if(user.getName().length()!=0&&user.getPassword().length()!=0){System.out.println(success);returnsuc;}else{System.out.println(fail);returnfail;}}3}?xmlversion=1.0encoding=UTF-8?!DOCTYPEstrutsPUBLIC-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.1//EN=defaultnamespace=/extends=struts-defaultactionname=Loginwnclass=shiyan9.Usersresultname=successStrutswelcome.jsp/resultresultname=falsefail.jsp/result/actionactionname=userclass=shiyan10.UserActionresultname=sucsuc.jsp/resultresultname=failfail.jsp/result/actionactionname=loginclass=shiyan10.UserActionmethod=loginresultname=sucsuc.jsp/resultresultname=failfail.jsp/result/actionactionname=registerclass=shiyan10.UserActionmethod=registerresultname=sucsuc.jsp/resultresultname=failfail.jsp/result/actionactionname=*userclass=shiyan10.UserActionmethod={1}resultname=sucsuc.jsp/resultresultname=fail{1}.jsp/result/action/package/struts%@pagelanguage=javaimport=java.util.*pageEncoding=utf-8%%@taglibprefix=suri=/struts-tags%s:formaction=user!login.actiontableClass=fieldtrtdcolspan=2class=error4s:fielderror//td/trtrtdclass=field用户名:/tdtds:textfieldname=user.namecssClass=textrequired=true//td/trtrtdclass=field密码:/tdtds:passwordname=user.passwordcssClass=textrequired=true//td/tr/tabledivclass=buttonss:submitvalue=立即登录//div/s:form%@pagelanguage=javaimport=java.util.*pageEncoding=utf-8%%@taglibprefix=suri=/struts-tags%s:formaction=user!register.actiontableClass=fieldtrtdcolspan=2class=errors:fielderror//td/trtrtdclass=field用户名:/tdtds:textfieldname=user.namecssClass=textrequired=true//td/trtrtdclass=field5密码:/tdtds:passwordname=user.passwordcssClass=textrequired=true//td/tr/tabledivclass=buttonss:submitvalue=立即注册//div/s:form(2)method%@pagelanguage=javaimport=java.util.*pageEncoding=utf-8%%@taglibprefix=suri=/struts-tags%s:formaction=login.actiontableClass=fieldtrtdcolspan=2class=errors:fielderror//td/trtrtdclass=field用户名1:/tdtds:textfieldname=user.namecssClass=textrequired=true//td/trtrtdclass=field密码:/tdtds:passwordname=user.passwordcssClass=textrequired=true//td/tr/tabledivclass=buttons6s:submitvalue=立即登录//div/s:form%@pagelanguage=javaimport=java.util.*pageEncoding=utf-8%%@taglibprefix=suri=/struts-tags%s:formaction=register.actiontableClass=fieldtrtdcolspan=2class=errors:fielderror//td/trtrtdclass=field用户名:/tdtds:textfieldname=user.namecssClass=textrequired=true//td/trtrtdclass=field密码:/tdtds:passwordname=user.passwordcssClass=textrequired=true//td/tr/tabledivclass=buttonss:submitvalue=立即注册//div/s:form(3)通配符%@pagelanguage=javaimport=java.util.*pageEncoding=utf-8%%@taglibprefix=suri=/struts-tags%s:formaction=register.actiontableClass=fieldtrtdcolspan=2class=errors:fielderror//td/tr7trtdclass=field用户名:/tdtds:textfieldname=user.namecssClass=textrequired=true//td/trtrtdclass=field密码:/tdtds:passwordname=user.passwordcssClass=textrequired=true//td/tr/tabledivclass=buttonss:submitvalue=立即注册//div/s:form(3)动态结果调用packageshiyan10;importcom.opensymphony.xwork2.ActionSupport;publicclassUserAction2extendsActionSupport{privateStringnextDispose;privateUseruser;privateStringmessage;publicUsergetUser(){returnuser;}publicvoidsetUser(Useruser){this.user=user;}publicStringgetMessage(){returnmessage;}publicvoidsetMessage(Stringmessage){this.message=message;}8publicStringlogin(){if(getUser().getName().endsWith(admin)&&getUser().getPassword().equals(admin)){nextDispose=manager;}else{nextDispose=common;}returnSUCCESS;}publicStringgetNextDispose(){returnnextDispose;}publicvoidsetNextDispose(StringnextDispose){this.nextDispose=nextD
本文标题:Struts2动态方法调用及通配符的使用
链接地址:https://www.777doc.com/doc-2861047 .html