Learn about MVC
MVC is the abbreviament of Model, View, Controller, MVC is the design pattern developed by Application. It is MODEL2 that everyone knows. In the MVC design mode, you request your business logic, interface display, data separation in Application development. That is, in Model, View, Controller implementation: data, control (business logic) display (page display). In the previous or traditional Web Application development methods, such as ASP, PHP, JSP (Model 1) is developed, we In ASP (PHP, JSP) implementation, such as: From the database to the data we need, and according to the relationship between the data and the actual needs, according to some way to display him in the page and submitted from the page. Extract data, query related data from the database according to business logic, or write data to the database. That is to say we implement everything in ASP (PHP, JSP): interface display, business logic, data access. The consequence of this is that the ASP (PHP, JSP) you are writing is not level, and HTML and Script (JavaScript, JSCript, ASP, PHP, JSP source code) are nesting each other. The maintenance is poor, the most interesting is in Web Application usually shows a piece of art, many times, you are also writing ASP, PHP, JSP and then beautifying, it is very likely that you have found that your code has been faced with it. You have to reorganize your code. The solution to this problem in the MVC mode is: VIEW is responsible for displaying, and view usually gets the data that has been processed from the Controller, and then displayed in the page, it should be said to nested very few Script in HTML. Basic artist Modifying that you will 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: XSP5: JSP Struts Javabean (EJB) I Personally think that there are two more than two, others have any places, especially using TDK because there is a better tool to automatically generate a lot of code, as for its shortcomings in several development methods, I will introduce.
The new features of Struts1.1 Struts1.1 and 1.0 have some very good features. The most important is that the function enhancement is enhanced. The verification of Struts1.1 data is not true in the Action before the Action, but the benefits of virtually the use of Validation.xml through configuration is a lot of reuse.
The main composition of Struts1.1 is mainly included in: Action, ActionForm, ActionMapping, ActionForward, the most important thing in development is that actionActionform can write or do not write as needed. Below I will introduce a specific introduction. ActionAn 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. Struts development team is above description of the Action that actually Action Request Business Logic and intermediate adapter. Popularity is to take the data from the form and wear a series of operations to the business logic operation and return the corresponding operational information.
ActionFormAn 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 called.ActionForm is actually taken from the data package to the Request And check, then the legal data is processed to the action. In addition to data checks, ActionForm is more important in addition to data checks. Instead, most of the data verification after 1.1 will be implemented in validation.xml. ActionMapping, ActionForwardActionMapping is mainly used with configuration and description related properties. First look at the configuration file in Struts-config.xml, one configuration description:
Build a struts1.1 Run environment My configuration is to discuss the Tomcat 4.0 or later, and the 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.zip2: Setting struts.jar Copy to $ Tomcat_home / COMMON / LIB or you add the following configuration under Web-INF / LIB under the APPACTION of Struts Add the following configuration under Web.xml under the web.xml
form-beans>
<-! Add multiple validator resource files by setting the pathname property ->
Struts-Config> I believe you can understand. I will not explain it.
You need to continue to configure Validation.xml, see the following simple example.