WEBAPP MVC This is a development framework that specializes in developing Internet programs, unlike the previous "EFW framework" usage, EFW is mainly used to develop rapid development of industry software, while WEBAPP differs from other MVC frameworks, such as ASPNET MVC, which is lighter and easier to use;
WebApp Technical Features:
Nvelocity (template engine) +urlrewriter+httphandler support for the underlying technology
Bootstrap+jqueryeasyui for front-end technical support
interface Effect : A simple website developed with WebApp, the appearance of simple atmosphere, using bootstrap to make the interface development becomes very easy, completely out of the annoying CSS design. The second picture combines Bootstrap and jqueryeasyui to develop some complex functions.
Source code directory structure : Divided into two projects,
WebUI for the interface project, the interface files are used static file HTML, and do not use the ASPX file, so that our publishing program becomes very convenient;
The manager project is the C # code of the controller and model, and the previous EFW framework should be familiar with the three directories of Businesentity, Dao and ObjectModel. This is the case that I use the object-oriented thinking and the actual development situation to solve the model of the scheme; the Controller class has a mapping relationship with the requested URL, and the controller can be called directly by entering the URL in the browser;
Execution Flowchart :
Combined with the above flowchart, we will explain the specific code situation.
Browser input address Http://localhost/views/newefw/[email Protected]_default will display the home page.
First urlrewriter the URL to/views/newefw/api.aspx?cmd=efw_default, the purpose of using Urlrewriter is to make the URL displayed on the browser appear easier to understand, the parsed user is difficult to understand, But we programmers should be easy to read;
And then to the api.aspx this core relay file, which is the key to map the URL to the controller, is the use of HttpHandler implementation, here we do not explain in detail, interested can check online.
And then look at Cmd=efw_default. This involves a configuration file Appunity.config, which is a mapping configuration file that configures the CMD and controller methods; here Efw_ Default is mapped to the default method of the Efwsitecontroller file;
We continue to look at Efwsitecontroller this controller file, in fact, is a normal CS file, wherein the method has two properties ViewData and Viewresult,
ViewData used to store interface data, Viewresult is through the Toview () method to the interface file HTML, through nvelocity parsing into the final interface code returned to the Viewresult output in the browser;
And the source of the ViewData data need to use model, here we do not discuss the model code in detail;
In addition, the default method adds a custom label [AOP (typeof (Headfootercomponent))] What's the use of this?
We know that the site generally includes the header and footer, these two parts exist on all pages, so in the design of the view for code reuse, We use external files to refer to head.htm and foot.htm so that the page solves the problem of code reuse, and how does the data back-end controller involved in the page solve? This is used to use the component component controller, and then through the AOP blocking component method to give no controller method plus the page footer data;
Here is just one way to solve the problem here, but it makes people look very intuitive;
Solution we look at the view file Default.htm code, there are nvelocity unique tag code, we write code can be simple to learn, and use it is very simple;
So far we have the first half of the flowchart has been introduced, that is, by entering a URL in the browser how to call the background controller, and resolve the view file display in the browser;
The second part is about how the view uses AJAX to request controller return data;
The following JS code is the code of the Jqueryeasyui DataGrid control request data, the URL specifies the method of the background controller;
The method of requesting a controller using AJAX is the same as the Controller method that returns the interface above, except that the returned data is stored with Jsonresult, and the data returned using the AJAX request is output in JSON format;
Summary : TheWebApp MVC principle is simple, using nvelocity to get rid of the ASPX code, and then the way the AJAX request controller and view URL request controller method together, so that development is easier Again is the bootstrap and Jqueryeasyui together to develop the interface is more characteristic, and the effect is very good;
WEBAPP MVC, "not the same" lightweight Internet application Development Framework