《Struts 2.ppt》由会员分享,可在线阅读,更多相关《Struts 2.ppt(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
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