ImageVerifierCode 换一换
格式:DOC , 页数:11 ,大小:133.04KB ,
资源ID:4571220      下载积分:5 金币
验证码下载
登录下载
邮箱/手机:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/4571220.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  
声明  |  会员权益     获赠5币     写作写作

1、填表:    下载求助     留言反馈    退款申请
2、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
3、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
4、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
5、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前自行私信或留言给上传者【二***】。
6、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
7、本文档遇到问题,请及时私信或留言给本站上传会员【二***】,需本站解决可联系【 微信客服】、【 QQ客服】,若有其他问题请点击或扫码反馈【 服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【 版权申诉】”(推荐),意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4008-655-100;投诉/维权电话:4009-655-100。

注意事项

本文(基于MVC模式的电子商务网站的分析及其设计应用.doc)为本站上传会员【二***】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4008-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

基于MVC模式的电子商务网站的分析及其设计应用.doc

1、Based on MVC Pattern Analysis and design of e-commerce (B2C)sitesBefore we start our journey into the internals of Spring MVC, we first need to understand the different layers of a web application. And well begin that discussion with a brief introduction of the MVC pattern in general, including what

2、 it is and why should we use it. After reviewing the MVC Pattern, we will go through the different layers in a web application and see what role each layer plays in the application. The Model View Controller pattern (MVC pattern) was first described by Trygve Reenskaug when he was working on Smallta

3、lk at Xerox. At that time, the pattern was aimed at desktop applications. This pattern divides the presentation layer into different kinds of components. Each component has its own responsibilities. The view uses the model to render itself. Based on a user action, the view triggers the controller, w

4、hich in turn updates the model. The model then notifies the view to (re)render itself.The MVC pattern is all about separation of concerns. As we mentioned previously, each component has its own role (see Table 3-1). Separation of concerns is important in the presentation layer because it helps us ke

5、ep the different components clean. This way, we dont burden the actual view with business logic, navigation logic, and model data. Following this approach keeps everything nicely separated, which makes it easier to maintain and test our application.What Is MVC:MVC is a design pattern that breaks an

6、application into three parts: the data (Model),the presentation layer (View), and the user interaction layer (Controller). In otherwords, the event flow goes like this:1. The user interacts with the application.2. The controllers event handlers trigger.3. The controller requests data from the model,

7、 giving it to the view.4. The view presents the data to the user.Or, to give a real example, Figure 1-1 shows how sending a new chat message wouldwork with Holla.Figure 1-1. Sending a new chat message from Holla1. The user submits a new chat message.2. The controllers event handlers trigger.3. The c

8、ontroller creates a new Chat Model record.4. The controller then updates the view.5. The user sees his new chat message in chat log.The MVC architectural pattern can even be implemented without libraries or frameworks.The key is to divide up the responsibilities of the MVC components into clearlydef

9、ined sections of code, keeping them decoupled. This allows for independent development,testing, and maintenance of each component.Lets explore the components of MVC in detail.The Model:The model is where all the applications data objects are stored. For example, we might have a User Model that conta

10、ins a list of users, their attributes, and any logic associated specifically with that model.A model does not know anything about views or controllers. The only thing a model should contain is data and the logic associated directly with that data. Any event handling code, view templates, or logic no

11、t specific to that model should be kept well clear of it. You know an applications MVC architecture is violated when you start seeing view code in the models. Models should be completely decoupled from the rest of your application.When controllers fetch data from servers or create new records, they

12、wrap them in model instances. This means that our data is object oriented, and any functions or logic defined on the model can be called directly on the data.So, rather than this:var user = usersfoo;destroyUser(user);We can do something like this:var user = User.find(foo);user.destroy();The first ex

13、ample is not namespaced or object oriented. If we have another destroyUser() function defined in our application, the two will conflict. Global variables and functions should always be kept to an absolute minimum. In the second example, the destroy() function is namespaced behind User instances, as

14、are all the stored records.This is ideal, since were keeping global variables to a minimum, exposing fewer areas to potential conflicts. The code is cleaner and can take advantage of inheritance so functions like destroy() dont have be defined separately on every model.Models are explored in much mo

15、re depth in Chapter 3, which covers topics such asloading in data from servers and creating object-relational mappers (ORMs).The View:The view layer is whats presented to the user and is what she interacts with. In a JavaScript application, the view would be made up mostly of HTML, CSS, and Java-Scr

16、ipt templates. Apart from simple conditional statements in templates, the views Should not contain any logic.In fact, like models, views should also be decoupled from the rest of the application.Views should not know anything about controllers and modelsthey should be independent.Mixing up views wit

17、h logic is one of the surest paths to disaster.That is not to say MVC does not allow for presentational logicas long as its not defined inside views. Presentational logic resides in what are called helpers: scripts solely for small utility functions related to the view.The example below, which inclu

18、des logic inside views, is something you should not do:/ template.htmlfunction formatDate(date) /* . */;$ formatDate(this.date) In the code above, were inserting the formatDate() function directly into the view,which violates MVC, resulting in an unmaintainable mess of tag soup. By separating out pr

19、esentational logic into helpers, as with the example below, were avoiding that problem and keeping our applications structure MVC-compliant./ helper.jsvar helper = ;helper.formatDate = function() /* . */ ;/ template.html$ helper.formatDate(this.date) In addition, all presentational logic is namespac

20、ed under the helper variable, preventing conflicts and keeping the code clean and extendable.Dont worry too much about specifics regarding views and templateswe cover them extensively in Chapter 5. The aim of this section is to familiarize you with how views relate to the MVC architectural pattern.T

21、he Controller:Controllers are the glue between models and views. Controllers receive events and input from views, process them (perhaps involving models), and update the views accordingly.The controller will add event listeners to views when the page loads, such as thosedetecting when forms are subm

22、itted or buttons are clicked. Then, when the user interacts with your application, the events trigger actions inside the controllers.You dont need any special libraries or frameworks to implement controllers; here is an example using plain old jQuery:var Controller = ;/ Use a anonymous function to e

23、nscapulate scope(Controller.users = function($)var nameClick = function()/* . */;/ Attach event listeners on page load$(function()$(#view .name).click(nameClick););)(jQuery);Were creating a users Controller that is namespaced under the Controller variable.Then, were using an anonymous function to en

24、capsulate scope, preventing variable pollution of the global scope. When the page loads, were adding a click event listener to a view element.As you can see, controllers dont require a library or framework. However, to comply with MVCs architectural requirements, they must be separated from Models a

25、ndViews. Controllers and states are covered in more detail in Chapter 4.基于MVC模式电子商务网站(B2C)分析和设计在我们开始进入Spring MVC神秘世界旅程之前,我们首先要了解web应用程序不一样层。简明介绍了MVC模式,我们将开始讨论这个问题,包含它是什么,为何要使用它。简单了解MVC模式后,我们将经过Web应用程序中不一样层,具体了解每一层在应用程序中饰演什么样角色。Trygve Reenskaug她在Smalltalk工作时首次描述了模型视图控制器模式(MVC模式)。当初,该模式关键应用和桌面应用程序,这个模

26、式把表示层分成了不一样类型组件,每个组件全部有自己不一样职责。视图利用模型来表现自己,视图在用户操作基础上触发控制器并依次更新模型,然后该模型通知视图更新其本身。MVC模式最关键就是关系独立。正如我们前面提到,每个组件有其自己作用(见下图)。在表示层关系独立是极其关键,因为它能够帮助我们让不一样组件保持代码简练。经过这种方法,我们不需要为视图现行导航逻辑、业务逻辑和模型数据而烦恼。根据这一措施,很好地保持了各组件关系独立,这使得我们更易于对应用程序进行维护和测试工作。MVC定义:MVC是一个设计模式,将应用程序分为三个部分:数据模型层(模型),表现层(视图),控制层(控制器)。换个说法说就是,

27、MVC设计模式运行机制以下:1、用户向服务器提交请求;2、控制器事件处理程序触发;3、控制器从模型中调用对应视图 ;4、将视图显示数据给用户。或,举一个形象例子,图1-1显示了怎样将一条新聊天消息发送给Holla处理:图1-1 从Holla发送一条新聊天信息1、用户提交新聊天消息;2、控制器事件处理程序触发;3、控制器创建一个新聊天模型统计;4、然后,控制器更新视图;5、在聊天统计中,用户能够看到她新聊天消息。MVC框架模式甚至能够实现无库或无框架模式。关键是要利用代码段明确定义独立MVC组件职责,保持它们独立。这就许可了每个组件独立开发,测试和维护。下面让我们来具体探讨MVC各组件。模型:模

28、型是应用程序中负责全部数据对象存放功效。比如,我们有一个用户模型,这个模型中包含了一系列用户,那么它们属性和和该模型相关任何逻辑全部会存放在这个模型中。模型和视图或控制器里数据没有任何关系。我们唯一知道是一个模型应包含和该数据直接相关数据和逻辑。不管是事件处理代码、视图模板、或逻辑,只要不是特定于该模型逻辑全部应该保持很明确独立关系。你要明白假如你在视图界面看到了模型中代码那就证实这个应用程序已经违反了MVC框架定义了。模型应该完全从你应用程序其它部分中独立出来。当控制器从服务器获取数据或创建新纪录时,她们是包装在模型实例中,这意味着,我们数据是面向对象,能够直接调用数据和模型上定义任何功效或

29、逻辑。也就是说,不是像下面这么:var user = usersfoo;destroyUser(user);我们应该像下面这么操作:var user = User.find(foo);user.destroy();第一个例子中实体不是命名空间或面向对象,假如我们在我们应用程序中定义了另一个destroyUser() 函数,那么二者将发生冲突。全局变量和函数应一直保持在绝对最小。在第二个例子中,destroy()函数命名空间在user实例以后,相当于包含了user实例里存放全部统计。这也是一个处理方法,因为我们全局变量一直保持最小,降低了暴露潜在冲突。这么话代码就更为简练而且能够继承,正如des

30、troy()方法并不需要在每一个模型里分别定义。在第3章节中我们会对模型进行更为深入探讨,其中包含从服务器数据加载和创建对象关系映射等。视图:视图层是展现给用户看到画面。在JavaScript应用程序中,视图大部是由HTML,CSS和JavaScript模版组成。除了模版中简单条件语句,视图层中不应该包含任何逻辑。实际上,比如模型,视图应该也能够从应用程序其它部分独立出来。视图应该和控制器和模型没有任何关系,它们应该是完全独立。将视图和逻辑混杂在一起必将使应用程序走向瓦解。这并不是说MVC不许可有表象逻辑,只要它没有定义在视图中,而是驻留在所谓辅助变量中:专为部分小功效准备视图脚本。下面例子,

31、其中包含视图内部逻辑,这是你不应该做事情:/ template.htmlfunction formatDate(date) /* . */;$ formatDate(this.date) 在上面代码中,我们将formatDate()函数直接放到视图中,这违反了MVC规则,造成难以维护多种杂乱标签组。经过将表象逻辑独立成辅助变量,以下面例子中,我们能够避免这一问题,而且保持我们应用程序结构和MVC兼容。/ helper.jsvar helper = ;helper.formatDate = function() /* . */ ;/ template.html$ helper.formatDat

32、e(this.date) 另外,全部表象逻辑命名在辅助变量之下,这么能够预防代码之间冲突而且保持代码简练性和可扩展性。我们不需要过分担心相关视图和模板细节,在第5章中我们会具体讲解。本节目标是让您熟悉视图怎样和MVC框模式联络起来。控制器:控制器是模型和视图之间桥梁。控制器从浏览器用户端收到请求,处理请求并反馈到视图中(可能包含模型),并对应地更新视图。当页面被加载时,假如检测到表单提交或点击按钮,控制器会将事件侦听器添加到视图中,然后,当用户和应用程序交互时,事件触发会控制器里中做出回应。你不需要任何特殊库或框架来实现控制器,这里是一个简单jQuery应用例子:var Controller

33、= ;/ Use a anonymous function to enscapulate scope(Controller.users = function($)var nameClick = function()/* . */;/ Attach event listeners on page load$(function()$(#view .name).click(nameClick););)(jQuery);我们创建了一个用户控制器命名空间下控制器变量,然后,我们在封装范围内使用了一个匿名函数,预防变量在整个系统范围内蔓延。当页面加载时,我们为一个视图元素添加了一个click事件侦听器。正如您能够看到,控制器不需要库或框架。不过为了遵从MVC框架要求,她们必需从模型和视图中分隔出来。控制器具体信息在第4章中。

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服