zhxy/http服务器/appweb-4.3.4-0/doc/guide/esp/users/mvc.html

126 lines
6.8 KiB
HTML

<!-- BeginDsi "dsi/head.html" -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Embedthis Appweb 4.3.4 Documentation</title>
<meta name="keywords" content="embedded web server, web server software, embedded HTTP, application web server,
embedded server, small web server, HTTP server, library web server, library HTTP, HTTP library" />
<meta name="description" content="Embedthis Sofware provides commercial and open source embedded web servers for
devices and applications." />
<meta name="robots" content="index,follow" />
<link href="../../../doc.css" rel="stylesheet" type="text/css" />
<link href="../../../print.css" rel="stylesheet" type="text/css" media="print"/>
<!--[if IE]>
<link href="../../../iehacks.css" rel="stylesheet" type="text/css" />
<![endif]-->
<link href="http://www.google.com/cse/style/look/default.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="top">
<a class="logo" href="http://appwebserver.org/">&nbsp;</a>
<div class="topRight">
<div class="search">
<div id="cse-search-form"></div>
<div class="version">Embedthis Appweb 4.3.4</div>
</div>
</div>
<div class="crumbs">
<a href="../../../index.html">Home</a>
<!-- EndDsi -->
&gt;<a href="index.html">ESP Guide</a>&gt; <b>Model-View-Controller Framework</b>
</div>
</div>
<div class="content">
<div class="contentRight">
<h1>Quick Nav</h1>
<ul class="nav">
<li><a href="#models">Models</a></li>
<li><a href="#views">Views</a></li>
<li><a href="#controllers">Controllers</a></li>
</ul>
<!-- BeginDsi "dsi/espSeeAlso.html" -->
<h1>See Also</h1>
<ul class="nav">
<li><a href="../../../guide/esp/users/using.html">ESP Overview</a></li>
<li><a href="../../../guide/esp/users/tour.html">ESP Tour</a></li>
<li><a href="../../../guide/esp/users/template.html">Templates and Layouts</a></li>
<li><a href="../../../guide/esp/users/controls.html">HTML Controls</a></li>
<li><a href="../../../guide/esp/users/config.html">ESP Configuration Directives</a></li>
<li><a href="../../../guide/esp/users/mvc.html">Model-View-Controller</a></li>
<li><a href="../../../guide/esp/users/generator.html">Application Generator</a></li>
<li><a href="../../../guide/esp/users/controllers.html">Controllers and Actions</a></li>
<li><a href="../../../guide/esp/users/database.html">Database Interface</a></li>
<li><a href="../../../guide/appweb/users/caching.html">Caching Responses</a></li>
</ul>
<!-- EndDsi -->
</div>
<div class="contentLeft">
<h1>Model-View-Controller Framework</h1>
<p>The Model-View-Controller (MVC) paradigm is a design pattern for creating applications. It
partitions the separate concerns of application data, user interface and application logic into three
discrete components. It has proven highly successful in simplifying application design and
maintenance.</p>
<img src="../../../images/mvc.jpg" alt="mvc" />
<p>The ESP Web Framework is a Model-View-Controller environment that provides a structure and
assistance for your MVC application. It provides the basis and connections between your models, views and
controllers and routes messages between the various components.</p>
<a id="models"></a>
<h2>Models</h2>
<p>The model is responsible for managing access to application data and state. It is also responsible for
ensuring the data remains valid and consistent.</p>
<p>ESP provides a basic Object Relational Mapper (ORM) via the Embedded Database Interface (EDI).
This wraps database data in a "C" language Record and Grid data structure. It then allows you to use
object-oriented programming (OOP) when dealing with database data stored in rows and columns. </p>
<a id="views"></a>
<h2>Views</h2>
<p>The view is responsible for rendering the user interface and presenting the application to the user.
Views should not manage incoming requests &mdash; that is the job of Controllers.</p>
<p>ESP provides the ESP web pages to assist in creating view web pages. ESP web pages are HTML
pages with embedded "C" code. They are compiled and run to render the user interface. The ESP view
mechanism also provides a templating engine so you can deal separately with layout pages and content pages.</p>
<a id="controllers"></a>
<h2>Controllers</h2>
<p>Controllers manage the application and respond to client requests. They orchestrate the application's
response, they access and update model data, and display views back to the client. Incoming requests invoke
<b>Actions</b> in the controller which modify the application state and ultimately render a view.</p>
<p>ESP routes requests by parsing and decoding request URIs and matching them with the appropriate
Controller and Action function.</p>
</div>
</div>
<!-- BeginDsi "dsi/bottom.html" -->
<div class="bottom">
<p class="footnote">
<a href="../../../product/copyright.html" >&copy; Embedthis Software LLC, 2003-2013.
All rights reserved. Embedthis, Appweb, ESP, Ejscript and Embedthis GoAhead are trademarks of Embedthis Software LLC.</a>
</p>
</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl(
'000262706376373952077:1hs0lhenihk');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.enableSearchboxOnly("http://appwebserver.org/search.html");
customSearchControl.draw('cse-search-form', options);
}, true);
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-179169-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>