SummaryStruts provides a very good MVC framework for separating the interface from the business logic in Web application development, increasing the reusability and flexibility of the code. This paper first introduces the concept and architecture of struts, and expounds the working principle of struts. Then it introduces the function modules of the estate property management system and the development process of the whole system based on struts. Finally, through an application example, the application of Struts framework in system development is introduced in detail.
Key WordsMvc;struts framework; Web; property management system;
Preface
The property management system is a new kind of industry which has arisen in recent years to adapt to the construction and management of the community, and its appearance has provided the guarantee for the modern management of the residential district. At present, the development methods of property management system are many, but most of the systems in the development of the system structure is complex, low code reuse rate, web design and software development mutual constraints lead to inefficient development and so on. In the process of system design, we consider the system structure, development cycle and code reuse, and decide to adopt advanced Java EE technology to develop this application system and implement the development mode of MVC (Model-view-controller) comprehensively. As a good MVC framework, struts is a good way to divide application logic, processing process and display logic into different component implementations, which can greatly facilitate code development and management and improve development efficiency for large and complex web systems. In view of this characteristic, in the design of the Community property Management system, we adopt the framework of struts based system construction model.
Struts
The architecture
As a well implemented MVC framework, struts provides the corresponding implementation components for model, view, and controller, as shown in Figure 1 in the Struts architecture diagram. The following is an introduction to struts architecture from models, views, and controls.
Fig. 1 The graph of the struts system
View is a series of JSP files submitted to the client browser for display, which is the interface that the user sees and interacts with. There is no business logic in these interfaces, no model information, only labels.
Model represents the state and business logic of an application, typically implemented by JavaBean or EJB components.
The role of the controller (Controller) is to accept the request from the client and choose to execute the appropriate business logic and then send the response back to the client. Controller in struts are implemented by the Actionservlet class and the action class. Actionservlet is primarily responsible for accepting HTTP request information, the action class is responsible for invoking the model's methods, updating the state of the model, and helping to control the application's process.
Residential Property Management System
1,
system Function Division
The property management system is an information management system used by the property department to comprehensively manage the building, household, equipment and personnel in the residential district. According to customer requirements, the system should be able to the community building, public equipment, household and other basic information to achieve input, modify, query and delete operations, and also to achieve including water, electricity, gas costs, such as the cost of the property management of the statistics, inquiries and report generation. Therefore, the realization of the Property Management system function module diagram is as follows:
Fig. 2 system function Module diagram
The functions implemented by each module are as follows:
(1) System Management module
The System Management module is the core of the whole property management system, which plays a key role in distinguishing different users ' use rights, enhancing the security of the software and guaranteeing the data security. Specific include: User management, user authorization, change password, system settings, system initialization, database backup, restore these modules.
(2) Household Management module
The module completes the registration of the basic information (name, population, housing area, etc.) of the new household and the modification, query and deletion of the existing household information, which is the basic function of the system. The module is divided into household registration, household modification, household modification, household enquiries and deletion of four sub modules.
(3) Equipment Management module
The module realizes the management of various public equipment (such as: street lamp, drainage pipe, etc.) in the community, establishes the information file for each equipment, records the equipment inspection, maintenance and maintenance records. Specifically divided into equipment registration, equipment repair, equipment inspection and equipment maintenance of these four modules.
(4) Real Estate Management module
The module is mainly aimed at the residential buildings, to achieve every building in the community, each building within each housing management, taking into account the owner of each unit of the purchase and sale changes, the module should also include the ownership of housing property management. The module is divided into: building drawing management, huxing drawing management, real estate ownership management.
(5) Personnel Management module
This module is mainly aimed at the staff of the property Management department to realize the management of the property management personnel, security/cleaning personnel. Including: Employee information entry, query, payroll management, staff attendance records and staff assessment records of these modules.
(6) Charge Management module
The module is mainly to achieve the tenants have been admitted to the costs (property management fees, water charges, electricity and gas charges) to pay the various aspects of management, including the following parts: Fee category settings, fee project settings, unit of measurement settings, table settings, users reading, receivables and receipts and so on.
2,
System Development Process
Using the B/S model of multi-layer frame structure development of the residential property management system, the MVC pattern mainly corresponds to the application server part, the front-end response to the user's request, the backend is responsible for the data transformation between the database server, the middle for the application of logic layer, responsible for the specific business processing. Based on the 3 basic components of the Struts framework: view, model and controller, the design process of the system is briefly described.
[4]。
(1) View design
The user interface of an application system is usually made up of JSP pages. In the system of six modules, all kinds of information to add, delete, modify and browse through the JSP page performance. The system handles each data representation mainly with two JSP pages: one page is used to add, delete, modify data, and another page is used for data browsing.
(2) Building the model
The struts application framework typically creates a actionform Bean in advance for each input form required for each application. If these beans are defined in the Actionmapping configuration file, the Struts controller servlet will automatically perform these preset actions. Therefore, in the system development, first establishes the corresponding Actionform Bean for each module, then according to each module actual function for each Bean defines the user operation State and the view need to display the data information the parameter, the view may carry on the different interface representation through the operation state different.
(3) Building the controller
In the Struts application framework, the central controller (ACTIONSERVLET) accepts all requests from the client and struts-config.xml the path of the user HTTP request to the other action object based on the system's configuration file. The central controller is provided by the struts framework itself, in the system development we do not need to actionservlet, and the action class responsible for the specific business processing is the focus of the system development.
After the view, model, and controller object design is complete, you need to edit two profiles: Web.xml and Struts-config.xml, which configure the interaction between each module in the struts system.
Strutsapplication of framework in system development
Residential Property Management system is a complex large-scale web application system, in order to be able to clearly describe the application of struts in the system development, this article will be a fee management module in the user successfully logged into the system and data entry and query this application as an example of a more detailed description.
1,Analyze Application Requirements In this application, the main events include:
(1) Provide user login interface, prompt the user to enter user name and password, and be able to the user input data in the client for simple data format verification. If the login is successful, transfer to the main operation interface, otherwise give the error message, login again.
(2) from the main operating interface into the property management fee entry interface, the user entered the form of relevant information (user ID, date), submit the form. If the form is submitted successfully, it is transferred to the confirmation interface to display the user input information.
(3) by the main operating interface into the query interface, the user input relevant information, query a certain period of time the user's property management costs.
(4) The user exits the system and returns to the main Menu page.
2,the specific design of the application
2.1 Database Design
For this application, you need to create two tables in the database: Porperty_table and user_table, each with the following table structure:
Table 1 user_table
Field |
Type |
Description |
UserName |
CHAR (25) |
Log the user name logged on to the system |
Password |
CHAR (25) |
Log the logon password for the logged-on user |
Table 2 porperty_table float (8)
|
type |
description |
ownerid |
char (8) |
record uniquely represents each user's ID |
date |
datetime (8) |
record payment date |
rare |
float (8) |
record the user's home area |
charge |
Records of property management fees to be paid |
|
char |
|
2.2 Design Model Components
In the struts framework, the model component is responsible for completing the business logic. In this application, the model component includes a utility class Dbconnect and two Jave Bean:userbean and Porpertybean.
The utility class Dbconnect is responsible for establishing a connection to the database, and provides a Connecttodb () method to implement the connection to the data and return the connection. Userbean represents user information, including the username and password properties. Porpertybean represents the property cost information, including ownerID, Data, ownername and several other attributes. These two javabean provide the corresponding Get/set methods, and they are also responsible for querying and adding/Querying records to the corresponding tables in the database.
2.3 User Interface Design
The user interface is a Web application and a user's window that can either accept user input or output information to the user. Table 3 lists the user interfaces used in the application and their descriptions.
Table 3 User interface and its description
Interface |
Description |
Welcome Interface (INDEX.JSP) |
Show welcome information, provide links to the login interface |
Login Interface (logon.jsp) |
Prompt for user name and password |
Main Operation Menu Interface (MAINMENU.JSP) |
Provides menu of all system actions |
Property charge Data Entry interface (INPUT.JSP) |
Prompt to enter information about property charges |
Fee Confirmation Interface (confirmation.jsp) |
According to the information entered by the user to return all the information of the user's property (such as: the fee payable, whether the payment has been paid, etc.) |
Property Fee Inquiry Interface (SEARCH.JSP) |
Provide user input related query criteria |
Show Query Results interface (DISPLAY.JSP) |
Display query results based on user query criteria |
In order to maintain consistency in all the interface styles in the application, in addition to using standard jsp<include> statements, we used the titles framework of struts to create a composite JSP page with the same headers and footers for all interfaces in the design of these interfaces.
2.4,Design Actionform
The Actionform bean is used to pass HTML form data between the view component and the controller component. Typically each HTML form corresponds to a actionform Bean, and each Actionform validate () method is used to implement format and syntax checking of user input data. The application contains three Actionform bean:logonform, Inputform and Searchform.
2.5,Design action and action mappings
In the struts framework, action implements the process control for each event, and the action mapping determines the association between the action and other Web Components. Table 4 lists the action used in the application, the entry for each action (the component that invoked the action), the actionform that is passed to the action, and the target component that each action forwards the request to.
Table 4 action in this application
Action |
Entrance |
Actionform |
Export |
Logonaction |
logon.jsp |
LogonForm |
mainmenu.jsp |
Inputaction |
input.jsp |
Inputform |
confirmation.jsp |
SearchAction |
search.jsp |
Searchform |
display.jsp |
Logoffaction |
mainmenu.jsp |
No |
index.jsp |
Figure 3 shows the mapping diagram of the action component and other components in the application.Figure 3 Action Mapping diagram
All of these action components need to configure their mapping relationships in the configuration file Struts-config.xml for struts.
the advantages of applying the Struts framework
(1) The whole property management system includes hundreds of files, if the traditional structure, to find out what a view is using what model to deal with the logic is a very complex thing. The application system developed by the struts framework relies on JSP and Struts-config.xml and the uniform naming rules between them, which makes it easy to survey, modify and understand the system process. As long as you find an action definition with the same name in the configuration file based on the action of the View form form, you know its path and the corresponding Formbean.
(2) All the logical processing in struts is encapsulated in class, the view part is no longer involved in the logical processing, the calculation and display are clearly separated, there is no processing on the JSP page, there is no data format in servlet or business logic. And based on the struts framework developed by the JSP code is also very concise, JSP page contains no Java code, only contains script and use the Struts tag Library of HTML, page developers do not have to modify the view and must first understand the model, to a large extent improve the efficiency of program development.
Concluding remarks
Struts is a good MVC framework, in modern software development, more and more applied to the development of large-scale web application systems. The successful development of the Community property management system based on the struts framework confirms that the struts framework is a very excellent J2EE/MVC implementation method. The property management system will provide a new working environment for the Property Management Department of the community, bring great convenience to the daily work of the property management, improve the working efficiency, and have good popularization value and application foreground.