ImageVerifierCode 换一换
格式:PPT , 页数:57 ,大小:174KB ,
资源ID:379159      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-379159.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Building Web Applications With The Struts FrameworkSession.ppt)为本站会员(eveningprove235)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

Building Web Applications With The Struts FrameworkSession.ppt

1、,Building Web Applications With The Struts FrameworkSession WE06 11/20/2002 10:00-11:00Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc.,Session Outline,Web Applications Backgrounder The Model-View-Controller Architecture The Struts Framework Building A Web Application With Struts Res

2、ources,Web Applications Backgrounder,Web Applications Backgrounder,Web applications run over the HTTP protocol: Request/response oriented Stateless Web applications use varied presentation (markup) languages, and talk to varied client hardware devices: “Standard HTML” - not! Varying dynamic and Java

3、Script capabilities Wireless devices vary in capabilities, language dialect, and input device support,Simple Solutions . for Simple Problems,For relatively simple applications, a simple architecture works fine For each page in the user interface . Create a servlet, JSP page, or something similar The

4、 page includes: Logic to create the user interface Logic to retrieve required information from the database Logic to perform the appropriate business transaction Logic to update the corresponding database information And its all mixed together in one source file This works fine for a Guest Book app,

5、 but what about something bigger?,What About Large Scale Applications?,Disparate skill sets required: Presentation Layer- User interface design, visual appearance, interaction model Application Layer Functional business logic to perform required transactions Persistence Layer Databases, directory se

6、rvers, messaging, Enterprise JavaBeansTM (EJBs) Application Deployment Networks, firewalls, public key infrastructures, load balancing, failover We need a fundamental organizing principle: The Model-View-Controller (MVC) architecture,The Model-View-Controller (MVC) Architecture,The Model-View-Contro

7、ller Architecture,Divides the overall functionality of an application into three layers: Model Layer Contains the functional business logic of the application, as well as a representation of the persistently stored data backing the application View Layer Contains the user interface, including mechan

8、isms to accept user input and render results Controller Layer Contains the logic that manages the flow of individual requests, dispatching to the appropriate business logic component,The Model Layer,Functional business logic: Should be modelled as JavaBeans or Session EJBs Should be reusable in non-

9、web environments API exposes public methods for each logical unit of work (while hiding the details) Persistent data storage: Should manage permanent storage of application data Typically shared across many applications API should expose data retrieval and storage operations (while hiding the mechan

10、isms),The View Layer,Creation of the user interface: Typically in HTML or an XML-based dialect Normally a combination of static and dynamic content Actual content varies depending on: Device or browser type User preferences / personalization Internationalization and localization requirements Accessi

11、bility requirements,The Controller Layer,Incoming requests flow through a common path: Received by common component Standardized request pre-processing Dispatch to request-specific model component (business logic) Forward to business-logic-specified view component Standardized request post-processin

12、g Often called “Model 2 Design” in the JSP/Servlet community In modern design pattern terminology, Struts implements the front controller pattern.,The Struts Framework An Implementation of the MVC Architecture,The Struts Framework Architecture,The Struts Framework Model Layer,Struts does not restric

13、t implementation techniques for model layer JDBC-accessed databases Enterprise JavaBeans O-R mapping tools Optional JDBC connection pool available Common design pattern: Action acquires information from persistence tier Exposes information as request/session attributes View layer pulls data from att

14、ributes for display,The Struts Framework View Layer,Form Bean maintains state of form input fields across requests: ActionForm Standard JavaBean design pattern DynaActionForm Property names and types defined in Struts configuration file In addition to properties, form beans define two standard metho

15、ds: reset() - Reset form properties to initial state validate() - Perform field-level validations Form bean properties are typically Strings Allows redisplay of invalid input,The Struts Framework View Layer,Internationalization Support enables locale-specific applications Locale Standard Java class

16、representing a choice of language and/or country MessageFormat Standard Java class representing an individual message with replaceable parameters: “0 is not a valid credit rating” MessageResources Struts abstraction around sets of messages for supported locales ActionErrors / ActionMessages Struts c

17、ollections of localized messages,The Struts Framework View Layer,JSP Custom Tag Libraries If you are using JSP pages for your presentation struts-bean.tld Fundamental bean manipulation and internationalization struts-html.tld “Smart” HTML elements struts-logic.tld Basic conditionals and iteration st

18、ruts-template.tld Basic layout management,The Struts Framework View Layer,Standard tag libraries added in Struts 1.1: struts-nested.tld - “Nested” variants of standard tags that resolve relative references against beans struts-tiles.tld Full features layout management library Contributed libraries a

19、dded in Struts 1.1: struts-xxx-el.tld Versions of standard Struts tag libraries that support the expression language syntax of JSP Standard Tag Library,The Struts Framework View Layer,Validation Framework No-code-required field level validations Configured in an XML document included in the web appl

20、ication Optionally generates client side JavaScript to enforce validation rules Extensible architecture,The Struts Framework Controller Layer,ActionServlet Standard implementation of controller At application startup, reads configuration file and initializes resources Struts 1.1 PlugIn General start

21、/stop hook On each request, implements the standard Struts request processing lifecycle (in Struts 1.1, implemented in RequestProcessor) Specialization / customization via subclassing Struts 1.1 Sub-application modules support,The Struts Framework Controller Layer,Action Standard base class for busi

22、ness logic components and adapters: Mapped to logical names by request processor Single instance per application (must be thread safe) Instantiated as needed, like servlets Implements the “Command Pattern” execute() - Invoked for each request Can (but typically does not) create response content dire

23、ctly Typically returns ActionForward to select resource to prepare response,The Struts Framework Controller Layer,Standard Request Processing Lifecycle 1: processLocale() - Record users locale preference (if not already present) processPreprocess() - general purpose pre-processing hook processMappin

24、g() - select Action to be utilized processRoles() - perform security role-based restrictions on action execution processActionForm() - Create or acquire an appropriate ActionForm instance,The Struts Framework Controller Layer,Standard Request Processing Lifecycle 2: processPopulate() - Copy the requ

25、est parameters into the form bean properties processValidate() - Call form beans validate() method processActionCreate() - Create or acquire an appropriate Action instance processActionPerform() - Call actions execute() method processActionForward() - Process returned ActionForward instance (if any)

26、,The Struts Framework Controller Layer,XML Configuration Document (/WEB-INF/struts-config.xml) Standard place to configure all aspects of the applications behavior DTD included for optional (but recommended) validation Logical-to-physical mappings for Actions, ActionForms, and ActionForwards General

27、 configuration settings Struts 1.1 Configuration Document per module if more than one,The Struts Framework Commons Libraries,Non-Struts Specific Logic Factored Out: commons-beanutils Generic bean property manipulation commons-collections Extensions to standard Java2 collections classes commons-dbcp

28、Optional JDBC connection pool commons-digester XML parsing for configuration files commons-fileupload Support library for HTML file uploads,The Struts Framework Commons Libraries,Non-Struts Specific Logic Factored Out: commons-logging Application logging wrapper commons-pool Object pooling library c

29、ommons-resources Message resources support library Commons-validator Field validation framework,Building Web Applications With Struts,Building Web Applications With Struts,Now that we understand the architecture of Struts, lets look at parts of an example app that is built with it Struts includes a

30、canonical example that is useful in determining whether you have installed things correctly struts-example.war Application models (part of) an email portal site that lets you maintain multiple subscriptions,Sample Application Model Layer (Persistence Tier),Modelled via a Data Access Object (DAO) org

31、.apache.struts.webapp.example.UserDatabasepublic interface UserDatabase public User createUser(String username);public void close() throws Exception;public User findUser(String username);public User findUsers();public void open() throws Exception;public void removeUser(User user);public void save()

32、throws Exception; ,Sample Application Model Layer (Persistence Tier),Default implementation based on loading an XML document into memory: o.a.s.e.memory.MemoryUserDatabase JDBC-based (or LDAP-based) implementation is easy to imagine, and would be transparent to the business logic Implementation sele

33、ction implemented via a PlugIn . see configuration file example later,Sample Application Model Layer (Business Logic),Two common Struts design patterns illustrated View View Action Welcome Page has link to logon page: . Logon page instantiates LogonForm bean Form submit goes to “/logon” action View

34、Action View Action Setup action “/editRegistration?action=Edit” pulls data from “database” and populates form bean Registration page “/registration.jsp” displays current data Form submit goes to “/saveRegistration” action,Sample Application View Layer (logon.jsp),Sample Application View Layer (logon

35、.jsp),Sample Application View Layer (logon.jsp),Sample Application Controller Layer,No application logic required Struts does everything for you :-) Controller functionality is configured via XML-based files: struts-config.xml Struts controller configuration validation.xml Validator framework config

36、uration web.xml Web application configuration,Sample Application Struts Configuration (struts-config.xml),.,Sample Application Struts Configuration (struts-config.xml),Sample Application Struts Configuration (struts-config.xml),Sample Application Struts Configuration (struts-config.xml),.,Sample App

37、lication Struts Configuration (struts-config.xml),Sample Application Struts Configuration (validation.xml),minlength3.,Sample Application Webapp Configuration (web.xml),Controllerorg.apache.struts.action.ActionServletconfig/WEB-INF/struts-config.xml1 ,Sample Application Webapp Configuration (web.xml

38、),Controller*.do .,Current Events,Struts 1.1 Release,When? “Real Soon Now” What new features? Apache Commons Libraries DynaActionForm Declarative Exception Handling Nested Tag Library PlugIn API Sub-Application Module Support (Contributed) STRUTS-EL Tag Libraries,Struts and JSTL,JSP Standard Tag Lib

39、rary (JSTL) 1.0: Expression language (“$customer.address“mailing”.city”) General purpose actions (out, set, remove, catch) Conditional actions (if, choose, when, otherwise) Iterator actions (forEach, forTokens) URL actions (import, url, redirect, param) Internationalization actions (message, setLoca

40、le, bundle, setBundle, message, param, requestEncoding) Formatting actions (timeZone, setTimeZone, formatNumber, parseNumber, formatDate, parseDate),Struts and JSTL,JSP Standard Tag Library (JSTL) 1.0, continued: SQL actions (not relevant in an MVC framework environment) XML core actions (parse, out

41、, set) XML flow control actions (if, choose, when, otherwise, forEach) XML transform actions (transform, param) The struts-xxx-el libraries are a bridge for Struts developers who want to leverage JSTL tags, and expression language syntax, now,Struts and JSF,JavaServer Faces (currently under developm

42、ent in JSR-127) Goals: Standard GUI component framework for web applications RenderKits for different rendering environments (browser vs. wireless device, different locales, etc.) Struts will provide an integration library: Requires changes to view layer and struts-config.xml file only! Plugs in to

43、RequestProcessor APIs,Resources,This Presentation Online,StarOffice 6.0: http:/www.apache.org/craigmcc/apachecon-2002-struts.sxi Powerpoint: http:/www.apache.org/craigmcc/apachecon-2002-struts.ppt,Internet Technologies,Hypertext Markup Language (HTML) 4.01: http:/www.w3.org/TR/html4/ Hypertext Trans

44、fer Protocol (HTTP) 1.1: http:/www.ietf.org/rfc/rfc2616.txt Uniform Resource Identifiers (URI): http:/www.ietf.org/rfc/rfc2396.txt,Model Layer Standard Java APIs,JavaBeans: http:/ Java Database Connectivity (JDBC): http:/ Java Data Objects: http:/ http:/jcp.org/jsr/detail/12.jsp Java Naming and Dire

45、ctory Interface: http:/ Enterprise JavaBeans (EJB): http:/ Layer Persistence Frameworks,Castor: http:/castor.exolab.org/ Java Data Objects: http:/ Object/Relational Bridge: http:/jakarta.apache.org/ojb/ Torque: http:/jakarta.apache.org/turbine/torque/,View Layer Standard Java APIs,Servlets: http:/ J

46、avaServer Pages (JSP): http:/ JSP Standard Tag Library (JSTL): http:/ JavaServer Faces: http:/ http:/jcp.org/jsr/detail/127.jsp,Struts Resources,The Struts and Commons Web Sites: http:/jakarta.apache.org/struts/ http:/jakarta.apache.org/commons/ Recent Books About Struts: Cavaness, Chuck; Programmin

47、g Jakarta Struts; OReilly Goodwill, James; Mastering Jakarta Struts; John Wiley Husted, Ted; Java Web Development With Struts; Manning Spielman, Sue; The Struts Framework: Practical Guide for Programmers; Morgan Kaufman Turner, James; Struts Kick Start; Sams,Design Patterns Resources,The Java Blueprints Web Site: http:/ Design Patterns Books: Gamma, Erich (et. al.); Design Patterns: Elements of Reusable Object-Oriented Software; Addison-Wesley Alur, Deepak (et. al.); Core J2EE Patterns: Best Practices and Design Strategies; Prentice Hall,Q & A,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1