MVC is the abbreviament of Model, View, Controller, MVC is the design pattern developed by Application, that is, everyone
Model2 you know. In the MVC design mode, you request your business logic, interface in Application development.
Display, data separation. That is, in Model, View, Controller: Data, Control (Business Logic)
Display (page display).
In the previous or traditional Web Application development methods, such as ASP, PHP, JSP (Model 1)
We implemented everything in ASP (PHP, JSP), such as: From the database to the data we need, and based on data
Related and actual needs to extract him in some way to the page and extract data from the form submitted by the page.
Business logic queries related data from the database, or writing data to the database. That is to say, we are in ASP (PHP, JSP)
Implementation: Interface Display, Business Logic, Data Access. The consequence of this is the ASP (PHP, JSP) you have written.
There is no level, and HTML and Script (JavaScript, JScript, ASP, PHP, JSP source code) are nesting each other.
The maintenance is poor, the most important thing is that the Web Application usually shows a piece of art, it is also a lot of time.
You write the ASP, PHP, JSP and then beautify it, it is likely that you find your code after you have finished working.
It has been unrecognizable. You have to reorganize your code.
The solution to this problem in the MVC mode is: VIEW is responsible for displaying, and view usually has been processed from Controller.
Data, then display it in the page, it should be said to nest in HTML, very small Script. Basic universal modification
I don't have a general meeting to abolish your labor results.
There are several developments that meet the MVC design model to make you choose from using Java Development Web Application.
1: JSP Servlet Javabean (EJB)
2: JSP Javabean (Controller) Javabean (EJB) (Model)
3: TDK (Turbine, Velocity ...)
4: XSP
5: JSP STRUTS JAVABEAN (EJB)
I personally think that there are two more than two kinds, others have any places, especially using TDK because there is a better
The tool can automatically generate a lot of code, as for its shortcomings in the comparison of several developments in the latter development, I will introduce.
Struts1.1 new features
Struts1.1 has some very good features compared to 1.0. The most important is that the function enhancement is enhanced. Struts1.1
The verification of the data is not implemented in the Action before the action, but is implemented through the Validation.xml.
The advantage of this is that the reuse is reinforced.
The main composition of struts1.1 implementation
Mainly include: action, actionform, actionmapping, actionforward, and development is an action
ActionForm writes or not written as needed. Below I will introduce a specific introduction.
Action
An action is an adapter Between the contents of an incoming http request
And The Corresponding Business Logic That Should Be Executed to Process this
REQUEST.
The above is a description of the Struts development team to Action, saying Action is actually Request and Business Logic
The intermediate adapter. It is common to take the data from the form and wear a series of operations to the business logic operation and then return the corresponding operation information.
Actionform
An actionform is a javabean optionally associated with one or more
ActionMappings. Such a Bean Will Have Had Its Properties Initialized from
The Corresponding Request Parameters Before The Corresonding Action's Execute ()
Method is caled.
The ActionForm is actually packaged and verped from the data taken from the request, and then gives the legal data to
Action is processed. In fact, ActionForm is more important in addition to data verification, in addition to writing
It is very effective. Instead, most of the data verification after 1.1 will be implemented in validation.xml.
ActionMapping, ActionForward
ActionMapping is mainly used in use with configuration and description related properties. First look at Struts-config.xml
A configuration description of the configuration file:
TYPE = "com.bingo.finance.action.useregaction" Name = "Usegegform" Scope = "request" Validate = "True" INPUT = "/ usereg.jsp"> action> action-mappings> ActionMapping is used to describe a URL of an action, a specific implementation file, corresponding ActionForm Data Attributes, whether data checksum is required, and maybe after processing is completed Jump URL. ActionForward you can understand the jump URL after the ACTION operation is completed, and the action is processed after processing. Returning is an actionforward to tell Struts I have finished this step. Build a struts1.1 operating environment My configuration is a discussion of Tomcat 4.0 or later, and other AppServer is roughly the same. 1: Get struts1.1 http://jakarta.apache.org/builds/jakarta-struts/release/v1.1-b1/jakarta-struts-1.1-b1.zip 2: Set Put Struts.jar Copy to $ TOMCAT_HOME / COMMON / LIB or you use the web-inf / lib under the spruts appaction Add the following configuration in Web.xml under Web.xml under the appaction of Struts init-param> init-param> servlet> taglib> taglib> taglib> taglib> Struts1.1 provides a very detailed example, you can take a closer look. Next you should configure struts-config.xml as needed, here is a simple example Xml Version = "1.0" encoding = "ISO-8859-1"?>
"- // Apache Software Foundation // DTD Struts Configuration 1.1 // en" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> TYPE = "com.bingo.finance.action.userform" /> form-beans> global-forwards> TYPE = "com.bingo.finance.action.useregaction" Name = "Usegegform" Scope = "request" Validate = "True" INPUT = "/ usereg.jsp"> action> action-mappings> Parameter = "com.bingo.finance.common.displaymsg" /> plug-in> Struts-Config> I believe you can understand. I will not explain it. You need to continue to configure validation.xml, see below Simple example. Depends = "Required, Mask, MINLENGTH, MAXLENGTH">
var>
var>
var> field> Depends = "Required, Mask, MINLENGTH, MAXLENGTH">
var>
var>
var> field> Depends = "Required, Mask, MINLENGTH, MAXLENGTH">
var>
var>
var> field> Depends = "Required, Mask, MINLENGTH, MAXLENGTH">
var>
var>
var> field> form> formset> form-validation> The above validation.xml is to tell Struts that my usegegform takes the following verification. UserName must not be empty and the minimum length is 5, the maximum length is 20. .............. Password, nickname, superpass basically I don't do more, the configuration is basically over, we have to start writing The first Struts. Develop struts1.1 Usereg.jsp In order to consider the flexibility of the page, all elements displayed in the page are placed in the Properties file and com.bingo.finance.common.htmlmsg This file is taken. ============================================================================================================================================================================================================= ================== <% @ Page contenttype = "text / html; charset = GBK"%> <% @ Page Import = "java.io. *"%> <% @ Page Import = "com.bingo.finance.common.htmlmsg"%> <% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%> <% @ Taglib URI = "/ Web-INF / STRUTS-LOGIC.TLD" prefix = "logic"%> <% @ Taglib Uri = "/ Web-INF / STRUTS-Bean.tld" prefix = "bean"%> hEAD>