《Struts 2.ppt》由会员分享,可在线阅读,更多相关《Struts 2.ppt(7页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、Struts 2WebFrameworksComparisonJUGMeeting#0002,8thofJuly2008July20081I.Origins and overviewI.Origins and overviewvAction based frameworkvMVC2 patternvPOJO basedJuly2008II.Basic ArchitectureII.Basic ArchitecturevThe web browser requests a resource(/mypage.action,etc)vThe Filter Dispatcher looks at th
2、e request and determines the appropriate Action vThe Interceptors automatically apply common functionality to the request,like workflow,validation,and file upload handling vThe Action method executes buisness code,returning a String result vThe Result renders the output to the browser,be it HTML,ima
3、ges,PDF,or something else July2008III.Core featuresIII.Core featuresOgnl expression languagesimilarwithjspexpressionlanguage+typeconversionsforMaps,ListsprimitivesnotjustforStrings+worksinothertemplateenviromentsvelocity,freemarker+callingmethods,lambdaexpressions+projectionselectingpropertiesfromli
4、stofobjectsandcreatinganothertemplist(usefullforaselect)ResultsManyresulttypesincludingjsp,velocity,freemarker,Jasperreports,Xsl,streamActions-Instantietedateveryrequestnothreadingissues-SimplePOJOswithanymethodsforexecute()-NottiedwiththeServletapibettertestability-NamespaceorganizationInterceptors
5、-Stackinginterceptors-ManyprebuildlikeParams,FileUpload,ModelDriven,TokenValue Stack-stackofdifferentscopesthatistraversedwhenlookingforavaluefromtheview:Temporaryobj,ModelObject,ActionObject,NamedObjects(#session),#request,#application,#parameters);-usesOgnltoreffertoscopedproperties-resolvesproper
6、tieswithsamenameindifferentscopeseg.1.userid-Tag library-basedonfreeMarkerallHTMLoutputproduced-bytagscanbeeasilycustomizedJuly2008 IV.Comparison criteriaslAjax supportlDojobuilt-in;fromversion2.1.0asapluginlPluginforJSONls:headtheme=“ajax”enablespartialsubmit,validationforformslManypre-buildajaxedc
7、omponentsliketabbedpane,tree,textarea,autocompleterlBookmarkabilitylHasnamespacessobookmarkingactionswithrequestparametersiseasylSmartURLfurtherenhancementslValidationlServersidevalidationinactionswithmethodsorannotationslClientvalidationwithxmldefinedvalidatorsmanyprebuildlikeemail,phonenumbers,any
8、regexlAjaxvalidationoutoftheboxwithDojo,canuseanyxmldefinedvalidatorsJuly2008IV.Comparison criteriaslTestabilitylTestingpossiblebymanuallyinstantiatingframeworkobjects:lDispatcherandActionProxyinstantiateactionslRequestandresponsecanbemokedwithobjectslikeMockServletContextservletContext,MockServletC
9、onfig,MockHttpServletRequest,MockHttpServletResponselExecutethedesiredMethodlPost and RedirectlSupportviaredirect-actionalsopossibilitytotransmitstaticordinamicparametersfromFirstactiontosecondlAlsoresovlesduplicatepostsviaTokenSessionInterceptorblockssubsequentrequestsuntilthefirstrequestiscomplete
10、lInternationalizationlResourceboundlesforinternationalizationverycustomizableatdifferentlevelslActionClass.propertieslInterface.propertieslAtpackagelevelpackage.propertieslGlobalresourcepropertiesviastruts.custom.i18n.resourcesdefinedinstruts.xmllAtUilevel,propertiesfetchedwithgetTextandi18ntagsJuly2008 IV.Comparison criteriaslPage decorationlPluginsforSitemeshandTiles2lToolslIntellijIdeafacetsforStruts2-autocompleteandsuggestionsJuly2008