信息科学与工程学院毕业设计科技文献翻译

查看源代码  时间:2021-03-21  阅读:()

《Struts——AnOpen-sourceMVCImplementation》《Struts——一种开源MVC的实现》姓名张三丰学号20140000年级2014级专业计算机科学与技术指导教师李双双2018年3月Struts——AnOpen-sourceMVCImplementationThisarticleintroducesStruts,aModel-View-ControllerimplementationthatusesservletsandJavaServerPages(JSP)technology.
StrutscanhelpyoucontrolchangeinyourWebprojectandpromotespecialization.
EvenifyouneverimplementasystemwithStruts,youmaygetsomeideasforyourfutureservletsandJSPpageimplementationIntroductionIfyouhaveworkedonalarge-scaleWebapplication,youunderstandthetermchange.
Model-View-Controller(MVC)isadesignpatternputtogethertohelpcontrolchange.
MVCdecouplesinterfacefrombusinesslogicanddata.
StrutsisanMVCimplementationthatusesServlets2.
2andJSP1.
1tags,fromtheJ2EEspecifications,aspartoftheimplementation.
YoumayneverimplementasystemwithStruts,butlookingatStrutsmaygiveyousomeideasonyourfutureServletsandJSPimplementations.
Model-View-Controller(MVC)JSPtagssolvedonlypartofourproblem.
Westillhaveissueswithvalidation,flowcontrol,andupdatingthestateoftheapplication.
ThisiswhereMVCcomestotherescue.
MVChelpsresolvesomeoftheissueswiththesinglemoduleapproachbydividingtheproblemintothreecategories:ModelThemodelcontainsthecoreoftheapplication'sfunctionality.
Themodelencapsulatesthestateoftheapplication.
Sometimestheonlyfunctionalityitcontainsisstate.
Itknowsnothingaboutthevieworcontroller.
ViewTheviewprovidesthepresentationofthemodel.
Itisthelookoftheapplication.
Theviewcanaccessthemodelgetters,butithasnoknowledgeofthesetters.
Inaddition,itknowsnothingaboutthecontroller.
Theviewshouldbenotifiedwhenchangestothemodeloccur.
ControllerThecontrollerreactstotheuserinput.
Itcreatesandsetsthemodel.
3.
StrutsSummary3.
1StrutsdetailsDisplayedinFigure1isastripped-downUMLdiagramoftheorg.
apache.
Struts.
actionpackage.
Figure6showstheminimalrelationshipsamongActionServlet(Controller),ActionForm(FormState),andAction(ModelWrapper).
Figure1UMLdiagramoftherelationshipoftheCommand(ActionServlet)totheModel(Action&ActionForm)3.
1.
1TheActionServletclassLifeisbetternowthatwehaveJavatechnology,XML,J2EE,andallthat.
TheStrutsControllerisaservletthatmapsevents(aneventgenerallybeinganHTTPpost)toclasses.
Andguesswhat--theControllerusesaconfigurationfilesoyoudon_thavetohard-codethevalues.
Lifechanges,butstaysthesame.
ActionServletistheCommandpartoftheMVCimplementationandisthecoreoftheFramework.
ActionServlet(Command)createsandusesAction,anActionForm,andActionForward.
Asmentionedearlier,theStruts-config.
xmlfileconfigurestheCommand.
DuringthecreationoftheWebproject,ActionandActionFormareextendedtosolvethespecificproblemspace.
ThefileStruts-config.
xmlinstructsActionServletonhowtousetheextendedclasses.
Thereareseveraladvantagestothisapproach:1)ThepagedesignerdoesnothavetowadethroughJavacodetounderstandtheflowoftheapplication.
2)TheJavadeveloperdoesnotneedtorecompilecodewhenmakingflowchanges.
3)CommandfunctionalitycanbeaddedbyextendingActionServlet.
3.
1.
2TheActionFormclassActionFormmaintainsthesessionstatefortheWebapplication.
ActionFormisanabstractclassthatissub-classedforeachinputformmodel.
WhenIsayinputformmodel,IamsayingActionFormrepresentsageneralconceptofdatathatissetorupdatedbyaHTMLform.
Forinstance,youmayhaveaUserActionFormthatissetbyanHTMLForm.
TheStrutsframeworkwill:ChecktoseeifaUserActionFormexists;ifnot,itwillcreateaninstanceoftheclass.
StrutswillsetthestateoftheUserActionFormusingcorrespondingfieldsfromtheHttpServletRequest.
Nomoredreadfulrequest.
getParameter()calls.
Forinstance,theStrutsframeworkwilltakefnamefromrequeststreamandcallUserActionForm.
setFname().
TheStrutsframeworkupdatesthestateoftheUserActionFormbeforepassingittothebusinesswrapperUserAction.
BeforepassingittotheActionclass,Strutswillalsoconductformstatevalidationbycallingthevalidation()methodonUserActionForm.
Note:Thisisnotalwayswisetodo.
TheremightbewaysofusingUserActionForminotherpagesorbusinessobjects,wherethevalidationmightbedifferent.
ValidationofthestatemightbebetterintheUserActionclass.
3.
1.
3TheActionclassTheActionclassisawrapperaroundthebusinesslogic.
ThepurposeofActionclassistotranslatetheHttpServletRequesttothebusinesslogic.
TouseAction,subclassandoverwritetheprocess()method.
TheActionServlet(Command)passestheparameterizedclassestoActionFormusingtheperform()method.
Again,nomoredreadfulrequest.
getParameter()calls.
Bythetimetheeventgetshere,theinputformdata(orHTMLformdata)hasalreadybeentranslatedoutoftherequeststreamandintoanActionFormclass.
3.
1.
4TheErrorclassesActionErrorencapsulatesanindividualerrormessage.
ActionErrorsisacontainerofActionErrorclassesthattheViewcanaccessusingtags.
ActionErrorsisStrutswayofkeepingupwithalistoferrors.
Figure2UMLdiagramoftherelationshipoftheCommand(ActionServlet)totheModel(Action)3.
1.
5TheActionMappingclassAnincomingeventisnormallyintheformofanHTTPrequest,whichtheservletContainerturnsintoanHttpServletRequest.
TheControllerlooksattheincomingeventanddispatchestherequesttoanActionclass.
TheStruts-config.
xmldetermineswhatActionclasstheControllercalls.
TheStruts-config.
xmlconfigurationinformationistranslatedintoasetofActionMapping,whichareputintocontainerofActionMappings.
(Ifyouhavenotnoticedit,classesthatendwithsarecontainers)TheActionMappingcontainstheknowledgeofhowaspecificeventmapstospecificActions.
TheActionServlet(Command)passestheActionMappingtotheActionclassviatheperform()method.
ThisallowsActiontoaccesstheinformationtocontrolflow.
3.
2Strutspros3.
2.
1UseofJSPtagmechanismThetagfeaturepromotesreusablecodeandabstractsJavacodefromtheJSPfile.
ThisfeatureallowsniceintegrationintoJSP-baseddevelopmenttoolsthatallowauthoringwithtags.
3.
2.
2TaglibraryWhyre-inventthewheel,orataglibraryIfyoucannotfindsomethingyouneedinthelibrary,contribute.
Inaddition,StrutsprovidesastartingpointifyouarelearningJSPtagtechnology.
3.
2.
3OpensourceYouhavealltheadvantagesofopensource,suchasbeingabletoseethecodeandhavingeveryoneelseusingthelibraryreviewingthecode.
Manyeyesmakeforgreatcodereview.
3.
2.
4SampleMVCimplementationStrutsofferssomeinsightifyouwanttocreateyourownMVCimplementation.
3.
2.
5ManagetheproblemspaceDivideandconquerisanicewayofsolvingtheproblemandmakingtheproblemmanageable.
Ofcourse,theswordcutsbothways.
Theproblemismorecomplexandneedsmoremanagement.
3.
3Strutscons3.
3.
1YouthStrutsdevelopmentisstillinpreliminaryform.
Theyareworkingtowardreleasingaversion1.
0,butaswithany1.
0version,itdoesnotprovideallthebellsandwhistles.
3.
3.
2ChangeTheframeworkisundergoingarapidamountofchange.
AgreatdealofchangehasoccurredbetweenStruts0.
5and1.
0.
YoumaywanttodownloadthemostcurrentStrutsnightlydistributions,toavoiddeprecatedmethods.
Inthelast6months,IhaveseentheStrutslibrarygrowfrom90Ktoover270K.
IhadtomodifymyexamplesseveraltimesbecauseofchangesinStruts,andIamnotgoingtoguaranteemyexampleswillworkwiththeversionofStrutsyoudownload.
3.
3.
3CorrectlevelofabstractionDoesStrutsprovidethecorrectlevelofabstractionWhatistheproperlevelofabstractionforthepagedesignerThatisthe$64Kquestion.
ShouldweallowapagedesigneraccesstoJavacodeinpagedevelopmentSomeframeworkslikeVelocitysayno,andprovideyetanotherlanguagetolearnforWebdevelopment.
ThereissomevaliditytolimitingJavacodeaccessinUIdevelopment.
Mostimportantly,giveapagedesigneralittlebitofJava,andhewillusealotofJava.
IsawthishappenallthetimeinMicrosoftASPdevelopment.
InASPdevelopment,youweresupposedtocreateCOMobjectsandthenwritealittleASPscripttoglueitalltogether.
Instead,theASPdeveloperswouldgocrazywithASPscript.
3.
3.
4LimitedscopeStrutsisaWeb-basedMVCsolutionthatismeantbeimplementedwithHTML,JSPfiles,andservlets.
3.
3.
5J2EEapplicationsupportStrutsrequiresaservletcontainerthatsupportsJSP1.
1andServlet2.
2specifications.
Thisalonewillnotsolveallyourinstallissues,unlessyouareusingTomcat3.
2.
IhavehadagreatdealofproblemsinstallingthelibrarywithNetscapeiPlanet6.
0,whichissupposedlythefirstJ2EE-compliantapplicationserver.
IrecommendvisitingtheStrutsUserMailingListarchive(seeResources)whenyourunintoproblems.
3.
3.
6ComplexitySeparatingtheproblemintopartsintroducescomplexity.
ThereisnoquestionthatsomeeducationwillhavetogoontounderstandStruts.
Withtheconstantchangesoccurring,thiscanbefrustratingattimes.
WelcometotheWeb.
FutureofStrutsThingschangerapidlyinthisnewageofsoftwaredevelopment.
Inlessthan5years,Ihaveseenthingsgofromcgi/perl,toISAPI/NSAPI,toASPwithVB,andnowJavaandJ2EE.
SunisworkinghardtoadaptchangestotheJSP/servletarchitecture,justastheyhaveinthepastwiththeJavalanguageandAPI.
YoucanobtaindraftsofthenewJSP1.
2andServlet2.
3specificationsfromtheSunWebsite.
Additionally,astandardtaglibraryforJSPfilesisappearing.
外文资料翻译译文Struts——一种开源MVC的实现英文作者:MalcolmDavis翻译:马运东文献来源:按毕业论文参考文献格式注明该外文文献来源这篇文章介绍Struts,一个使用servlet和JavaServerPages技术的一种Model-View-Controller的实现.
Struts可以帮助你控制Web项目中的变化并提高专业化.
即使你可能永远不会用Struts实现一个系统,你可以获得一些想法用于你未来的servlet和JSP网页的实现中.

简介如果你开发过大型Web应用程序,你就理解"变化"这个词语.
"模型-视图-控制器"(MVC)就是用来帮助你控制变化的一种设计模式.
MVC减弱了业务逻辑接口和数据接口之间的耦合.
Struts是一种MVC实现,它将Servlet2.
2和JSP1.
1标记(属于J2EE规范)用作实现的一部分.
你可能永远不会用Struts实现一个系统,但了解一下Struts或许使你能将其中的一些思想用于你以后的Servlet和JSP实现中.

模型-视图-控制器(MVC)JSP标签只解决了我们问题中的一部分.
我们依然有验证、流控制、以及更新应用程序结构的问题.
MVC通过把问题分成三类来帮助解决一些与单模块相关的问题:Model(模型)模块包括应用程序功能的核心.
模型封装着应用程序的各个结构.
有时它所包含的唯一功能就是结构.
View(视图)视图提供了模型的演示.
它是应用程序的外表.
视图可以进入模型获得者,但是它对于设置者一无所知.
视图仅仅当模型发生改变的时候才被通知.
Controller(控制器)控制器对于用户的输入做出反应.
它创造和设置模型.
3.
Struts概览3.
1Struts详细资料在图6中展示了一个无其他附属设备的阿帕奇Struts的action包的UML图表.
图1显示了ActionServlet(Controller)、ActionForm(FormState)和Action(ModelWrapper)之间的最小关系.

图1命令(ActionServlet)与模型(Action&ActionForm)之间的关系的UML图3.
1.
1ActionServlet类现在日子好过多了,自从我们有了Java技术、XML、J2EE等等之后.
Struts控制器是一个映射事件(事件通常是一个HTTPpost)到类的一个servlet.
猜猜怎么着--控制器用一个配置文件以致于你不必非硬编码这些值.
生活变了,但方法依然如此.

ActionServlet是MVC实现的命令部分并且它是框架的核心.
ActionServlet(Command)创建并使用Action、ActionForm和ActionForward.
正如前面所提及的,Struts-config.
xml文件配置Command.
在Web工程创建期间,Action和ActionForm被扩展用来解决特殊的问题空间.
文件Struts-config.
xml指导ActionServlet如何扩展这些类.
这种方法有几个优点:1)网页设计人员不必费力地通过Java代码来理解应用程序的流程.
2)当流程发生改变时Java开发人员不需要重新编译代码.
3)通过扩展ActionServlet命令函数可以被添加进来.
3.
1.
2ActionForm类ActionForm维持着Web应用程序的会话状态.
ActionForm是一个必须为每个输入表单模型创建该类的子类的抽象类.
当我说输入表单模型时,我就是说ActionForm代表了一个由HTML表单设置或更新的一般意义上的数据.
例如,你可能有一个由HTML表单设置的UserActionForm.
Struts框架将会:检查UserActionForm是否存在;如果不存在,它将会创建该类的一个实例.
Struts将使用HttpServletRequest中相应的域设置UserActionForm的状态.
没有太多糟糕的请求.
getParameter()调用.
例如,Struts框架将从请求流中提取fname并调用UserActionForm.
setFname().
Struts框架在将在传递它到业务包装UserAction之前将更新UserActionForm的状态.
在传递它到Action类之前,Struts将还会对UserActionForm调用validation()方法进行表单验证.

备注:这样做通常并不明智.
别的网页或业务对象可能有方法使用UserActionForm,然而验证可能不同.
在UserAction类中进行状态验证可能更好.
UserActionForm能够维持一个会话级别.
Struts-config.
xml文件控制着HTML表单请求与ActionForm之间的映射.
多重请求会被映射到UserActionForm.
UserActionForm可被映射到诸如向导之类的多重页面的东西上.

3.
1.
3Action类Action类是一个围绕业务逻辑的一个包装器.
Action类的目的就是将HttpServletRequest翻译给业务逻辑.
要使用Action,需重写process()原理.

ActionServlet(命令)通过使用perform()原理将参数化的类传递给ActionForm.
此外,没有太多讨厌的request.
getParameter()调用.
通过事件到达这里的时间,输入表单数据(或HTML表单数据)已经被从请求流中翻译出来并进入ActionForm类中.

备注:扩展Action类时请注意简洁.
Action类应该控制应用程序的流程,而不应该控制应用程序的逻辑.
通过将业务逻辑放在单独的包或EJB中,我们就可以提供更大的灵活性和可重用性.
3.
1.
4Error类ActionError封装了单个错误消息.
ActionErrors是ActionError类的容器,View可以使用标记访问这些类.
ActionError是Struts保持错误列表的方式.

图2Command(ActionServlet)与Model(Action)之间的关系的UML图3.
1.
5ActionMapping类输入事件通常是在HTTP请求表单中发生的,servlet容器将HTTP请求转换为HttpServletRequest.
控制器查看输入事件并将请求分派给某个Action类.
Struts-config.
xml确定Controller调用哪个Action类.
Struts-config.
xml配置信息被转换为一组ActionMapping,而后者又被放入ActionMappings容器中.
ActionMapping包含有关特定事件如何映射到特定Action的信息.
ActionServlet(Command)通过perform()方法将ActionMapping传递给Action类.
这样就使Action可访问用于控制流程的信息.

3.
2Struts的优点3.
2.
1JSP标记机制的使用标记特性从JSP文件获得可重用代码和抽象Java代码.
这个特性能很好地集成到基于JSP的开发工具中,这些工具允许用标记编写代码.
3.
2.
2标记库为什么要另发明一种轮子,或标记库呢如果你在库中找不到你所要的标记,那就自己定义吧.
此外,如果你正在学习JSP标记技术,则Struts为你提供了一个起点.
3.
2.
3开放源码你可以获得开放源码的全部优点,比如可以查看代码并让使用库的每个人检查代码.
许多人都可以进行很好的代码检查.
3.
2.
4MVC实现样例如果你希望创建你自己的MVC实现,则Struts可增加你的见识.
3.
2.
5管理问题空间分治是解决问题并使问题可管理的极好方法.
当然,这是一把双刃剑.
问题越来越复杂,并且需要越来越多的管理.
3.
3Struts的缺点3.
3.
1仍处于发展初期Struts开发仍处于初级阶段.
他们正在向着发行版本1.
0而努力,但与任何1.
0版本一样,它不可能尽善尽美.
3.
3.
2仍在变化中这个框架仍在快速变化.
Struts1.
0与Struts0.
5相比变化极大.
为了避免使用不赞成使用的方法,你可能隔一天就需要下载最新的Struts.
在过去的6个月中,我目睹Struts库从90K增大到270K以上.
由于Struts中的变化,我不得不数次修改我的示例,但我不保证我的示例能与你下载的Struts协同工作.

3.
3.
3正确的抽象级别Struts是否提供了正确的抽象级别对于网页设计人员而言,什么是正确的抽象级别呢这是一个用$64K的文字才能解释清楚的问题.
在开发网页的过程中,我们是否应该让网页设计人员访问Java代码某些框架(如Velocity)说不应该,但它提供了另一种Web开发语言让我们学习.
在UI开发中限制访问Java有一定的合理性.
最重要的是,如果让网页设计人员使用一点Java,他将使用大量的Java.
在MicrosoftASP的开发中,我总是看到这样的情况.
在ASP开发中,你应该创建COM对象,然后编写少量的ASP脚本将这些COM对象联系起来.
但是,ASP开发人员会疯狂地使用ASP脚本.

3.
3.
4有限的适用范围Struts是一种基于Web的MVC解决方案,所以必须用HTML、JSP文件和servlet来实现它.
3.
3.
5J2EE应用程序支持Struts需要支持JSP1.
1和Servlet2.
2规范的servlet容器.
仅凭这一点远不能解决你的全部安装问题,除非使用Tomcat3.
2.
我用NetscapeiPlanet6.
0安装这个库时遇到一大堆问题,按理说它是第一种符合J2EE的应用程序服务器.
我建议你在遇到问题时访问Struts用户邮件列表的归档资料.

3.
3.
6复杂性在将问题分为几个部分的同时也引入了复杂性.
毫无疑问,要理解Struts必须接受一定的培训.
随着变化的不断加入,这有时会令人很沮丧.
欢迎访问本网站.
4.
Struts的前景在软件开发的新时代事物都变化得很快.
在最近5年里,我目睹过事物从cgi/perl,再到ISAPI/NSAPI、再到使用VB的ASP、一直到现在的Java和J2EE的变迁.
Sun正在努力地适应JSP/servlet结构,就像他们通过Java语言和API在过去.
你可以从Sun的网站获得新的JSP1.
2和Servlet2.
3规范的草案.
此外,一个标准的JSP标记库正在出现.

LOCVPS:美国XEN架构VPS七折,全场八折,日本/新加坡XEN架构月付29.6元起

LOCVPS发来了针对XEN架构VPS的促销方案,其中美国洛杉矶机房7折,其余日本/新加坡/中国香港等机房全部8折,优惠后日本/新加坡机房XEN VPS月付仅29.6元起。这是成立较久的一家国人VPS服务商,目前提供美国洛杉矶(MC/C3)、和中国香港(邦联、沙田电信、大埔)、日本(东京、大阪)、新加坡、德国和荷兰等机房VPS主机,基于XEN或者KVM虚拟架构,均选择国内访问线路不错的机房,适合建...

GigsGigsCloud($26/年)KVM-1GB/15G SSD/2TB/洛杉矶机房

GigsGigsCloud新上了洛杉矶机房国际版线路VPS,基于KVM架构,采用SSD硬盘,年付最低26美元起。这是一家成立于2015年的马来西亚主机商,提供VPS主机和独立服务器租用,数据中心包括美国洛杉矶、中国香港、新加坡、马来西亚和日本等。商家VPS主机基于KVM架构,所选均为国内直连或者优化线路,比如洛杉矶机房有CN2 GIA、AS9929或者高防线路等。下面列出这款年付VPS主机配置信息...

RackNerd:便宜vps补货/1核/768M内存/12G SSD/2T流量/1G带宽,可选机房圣何塞/芝加哥/达拉斯/亚特拉大/荷兰/$9.49/年

RackNerd今天补货了3款便宜vps,最便宜的仅$9.49/年, 硬盘是SSD RAID-10 Storage,共享G口带宽,最低配给的流量也有2T,注意,这3款补货的便宜vps是intel平台。官方网站便宜VPS套餐机型均为KVM虚拟,SolusVM Control Panel ,硬盘是SSD RAID-10 Storage,共享G口带宽,大流量。CPU:1核心内存:768 MB硬盘:12 ...

查看源代码为你推荐
neworiental天津新东方总部地址在哪里?硬盘工作原理简述硬盘的工作原理。xyq.163.cbg.comhttp://xyq.cbg.163.com/cgi-bin/equipquery.py?act=buy_show_equip_info&equip_id=475364&server_id=625 有金鱼贵吗?haokandianyingwang谁有好看电影网站啊、要无毒播放速度快的、在线等m.2828dy.comwww.dy6868.com这个电影网怎么样?avtt4.comCOM1/COM3/COM4是什么意思??/抓站工具一起来捉妖神行抓妖辅助工具都有哪些?菊爆盘请问网上百度贴吧里有些下载地址,他们就直接说菊爆盘,然后后面有字母和数字,比如dk几几几的,机器蜘蛛挑战或是生存Boss是一只巨型机器蜘蛛的第一人称射击游戏叫什么www.qqq147.comhttp://www.qq
怎么注册域名 欧洲免费vps 阿里云邮箱登陆首页 bbr kdata la域名 宕机监控 ixwebhosting ibox官网 vip购优汇 ftp教程 789电视 ftp免费空间 免费网页申请 腾讯总部在哪 空间购买 www789 百度云加速 lamp怎么读 lamp的音标 更多