Design and implementation of insurance business management system (thesis + PPT + source code)

Classification number_______________ Classification_______________

UDC _______________ Student Number_ _

Graduation Design (Thesis)

student name
student ID
Faculty
professional class
Tutor's name and title
Completion Date
Essay topic Design and Realization of Insurance Business Management System
Thesis Topic Insurance business management system

Summary

After more than 20 years of rapid development, the market competition in my country's insurance industry has reached a feverish level. In the same city, dozens of entities often participate in the competition for insurance business. The competition among insurance companies is extremely fierce. If they want to stand out in this complex and ever-changing market environment, they must manage their business well. The majority of policyholders have become more picky while enjoying the benefits brought by competition. Which insurance company can provide better services often becomes the key factor in their final decision. In this environment, more and more insurance companies use management systems to provide better services. At present, the business and management information platforms of insurance companies are mostly built according to the original internal development ideas. Once there are new application requirements, the newly developed system has to consider the separate integration with the previous system. The upgrade of the old system will trigger a large number of system updates and testing work. Therefore, a good system is very important for enterprises.

Keywords: Internet; insurance industry; Mysql; SSH; B/S;

Abstract

After more than twenty years of rapid development, China's insurance industry market competition has reached a white hot degree, in the same city, there are often several main players compete in the insurance business. The majority of households in the enjoyment of the benefits brought by the competition has become more critical, which insurance companies can provide better service is often a key factor in the final decision. In this environment, more and more insurance companies use the management system to provide better service. At present, the insurance company's business and management information platform, mostly with the original internal development ideas. Once a new application is required, the newly developed system will be considered separately from the previous system. The upgrading of the old system will lead to a large number of system updates and testing. So a good system is very important to the enterprise.

Key words : Internet; Insurance Industry; Mysql; SSH; B/S;

Table of contents

1. Research background and significance 1 (1) Research background 1 (2) Industry background 2 (3) Domestic and international status 3 (4) Research significance 4 2. System development technology 5 (1) System development tools 5 (2) System development Environment 9 III. System Analysis 10 (1) Feasibility Analysis 10 (2) Demand Analysis 12 4. Overall System Design 14 (1) System Design 14 (2) System Structure Design 16 (3) Database Relationship Diagram 16 (4) System Use Case Diagram 17 V. System Detailed Design and Implementation 19 (1) System Detailed Design 19 (2) Module Implementation 22 6. System Test 29 Acknowledgments 36 7. Foreign Language Translation 37

Research Background and Significance

Research Background

The rapid growth of science and technology, due to the continuous improvement of science and technology and the expansion of social production, the level of human science and technology has been greatly enhanced, the prosperity of human civilization and thought is becoming more and more powerful, and the speed of flexible thinking is accelerating at a super speed. The trend of increasingly severe competition in the market has caused a fundamental change in people's concept of news. News has become the third largest material for the development of human society concurrently with it after materials and power.

Today, with the basic popularization of computers, the development of network technology has made it no longer strange to work from home. Almost every household has more than one network device. According to the latest data, as of September 2016, the number of Internet users in China has reached 740 million, and the Internet penetration rate has exceeded 50%, which shows the high spread rate of the Internet. Obviously, the Internet has gradually become an area of ​​our life. The increasingly perfect Internet links and the increasing transformation of Internet technologies have finally led to the gradual development of various Internet application technologies according to needs.

In today's society, when facing losses and disasters, people usually hope to ensure the safety of their property, and they also try various methods to avoid some losses in life, so the insurance business can come in handy. From ancient times to the present, people Everyone has the awareness of insurance. Human society has always been troubled by natural disasters and accidents. When people compete with nature, they have insurance against accidents and injuries. The successive dynasties of our country have attached great importance to the storage of grain. Confucius, known as the sage of Confucius, put forward the idea of ​​"cultivating three more than one" which is quite representative. In foreign countries, there was a kind of mutual aid fund organization among stonemasons in ancient Egypt. The organization collected membership fees from each member. The soldier organizations in the fallen horse will use the collected membership fees to comfort the families of the dead soldiers. This is the prototype of the original insurance. Modern insurance originated in Italy. In the middle of the 14th century, the oldest insurance in the world appeared, which was the embryonic form of marine insurance. After that, safe practices spread rapidly throughout Europe. By the 17th century, London had become a major player in the global insurance industry. Purpose. Established Hua'an Hequn Life Insurance Unit in Shanghai, which is the first Chinese property owner insurance unit in China. In the 21st century, insurance has become an indispensable part of people's life. All kinds of insurance business are ubiquitous in real life, and have become an indispensable business for people's normal life. Due to the development of society and the enhancement of people's awareness of insurance, the number of insurance businesses has increased rapidly. However, in order to ensure the sustainable growth of the company's business, the insurance company has cultivated an efficient and well-trained sales force, and established its own branches in various regions to expand the insurance business to record the detailed information of all policyholders , but until now, handwork is still the main form of recording.

With the gradual increase of the insurance market, the insurance subject market has been gradually completed. Before 1988, only the People's Insurance Company of China operated in my country's insurance market. Since 1988, with the establishment of Anping Insurance Company and Pacific Insurance Company, the pattern of private operation of the security situation has been broken. As of the end of 2011, there were a total of 158 domestic state-owned Chinese-funded and foreign insurance companies. In addition, insurance intermediaries are enterprises and individuals who are engaged in insurance intermediary services between insurance institutions or between insurance institutions and policyholders, and obtain commissions from them in accordance with regulations. The department has also been growing. As of the end of December 2010, there were about 2,461 occupational insurance purchasing agents, safety economic enterprises, and safety public estimation enterprises in our national insurance market, and the insurance intermediary market was first formed.

The multiple aspects of the main security market have effectively promoted changes in the management awareness of insurance companies, making them gradually establish service thinking, competition thinking, benefit thinking and development thinking. The expansion of the security market has gradually shifted from quantity to quality.

However, with the expansion of business and the increase in the number of insurance participants, more and more information must be recorded. It is time-consuming and inefficient for employees to search for customer information from thousands of data files stored in hard disks every day. And boring. Therefore, in order to manage and process customer information and business operation information reasonably and conveniently, the insurance company allows customers, employees, and administrators to conveniently have their own authority and operate their own information modules, and establish an efficient management system with the help of a modern computer technology. Information systems are key.

business background

Insurance refers to the industry in which the capital collected through the agreed mode is used to supplement the pecuniary profits of the protected person.

Security means that the investor receives security money from the client according to the contract, and the client is responsible for compensation for the loss of the property caused by the event that may break out in the contract, or when the client dies, is injured or dies, and reaches the age and deadline agreed in the contract Timely bear the responsibility of paying security fees.

The security market is a place where business security is signed by both parties. It can be a centralized market, or it can be a scattered market without sex.

According to the different subject matter of insurance, insurance can be divided into two categories: property insurance and personal insurance.

Security money refers to the security of property and its related responsibilities, including money loss insurance, liability insurance, trustworthiness insurance, surety insurance, farmer insurance, etc. It is a compensatory insurance in which property and its related interests are the subject of insurance.

Life insurance is a business that uses life and body for safety. When people encounter disasters or lose work strength, become disabled, die or get laid off due to old age due to illness or old age, according to the safety contract, the customer pays insurance money or year-end bonus to the insured or beneficiaries to cover their illness, Loss of gold coins caused by disability, old age, and death.

According to whether there is a direct relationship with investors, security can be changed into primary insurance and secondary insurance. The security move between the insurer and the policyholder is called the original insurance. The insurance behavior between the insurer and the insurer is called secondary insurance.

Status quo at home and abroad

  1. Domestic status quo
    With more diversified asset allocation, the problem of aging society in China is becoming more and more prominent. The huge insurance demand is still the driving force behind the growth of domestic life insurance premium income. Therefore, it is expected that the overall premium income of domestic life insurance companies will continue to grow in the next year. According to estimates, Premium growth is expected to reach 10% in 2017. The rapid growth of insurance premiums also indicates the rapid increase of insurance business, and the subsequent management problems and work efficiency problems are also magnified.
    After my country joined the World Trade Organization, foreign insurance also had a major impact on my country's business. my country's insurance business began to reflect the characteristics of internationalization, which was of great help to the expansion of China's insurance industry. New The company's development situation has had a great impact on the development of the traditional insurance industry. Yes, it has greatly increased the company's ability requirements, so the dependence on insurance management has been strengthened a lot. A good management system Can help the company stand out and become a leader in the insurance industry. The quality of the information system will directly affect the development of the company. The quality of the information management system is the key for future insurance companies to understand competitors in the competition.
    The current communication structure can no longer better meet the requirements of the industry's procedures and processing measures, Micro Motion's side, and it is not enough to measure the standards of the country and the leaders have instructed all regions to create their own information projects according to the situation of the region. In some places, the structural projects did not comply with the intention and design requirements of the standard, resulting in multiple developments of the software; the Internet connection was blocked; there is no accurate source of money for the construction of the news system, and the money for the establishment of the news system is obviously insufficient; there is a lack of structure and Elite capabilities ensured. External security intermediary organizations do not have professional and practical external operation departments in many regions. The lack of computer elites in the social security intermediary sector seriously restricts the establishment and development of the entire insurance news system. So the realization of the design of the insurance business management system is very important.
  2. Status abroad

Due to the temporary regional knowledge and communication of news templates, as well as the accumulation of experience in clarifying and designing security salesman software over the years, foreign security business facilities have certain advantages in the construction of digital templates, which are specifically reflected in these aspects, First, have a perfect data dictionary. The data dictionary is the basis of the entire application system, which includes the classification and definition of various data items, and is the cornerstone of the insurance industry application software. Second, data values ​​are standardized. Comprehensive data value definition is the basis of system standardization, which ensures the integrity, consistency and operability of the software system. Third, data entities and relationships. On the basis of data items, data entities and relationships are the most effective way to express insurance industry knowledge and occupy an important position in information system models.

Many foreign systems have been in use for 20-30 years, and have accumulated various successes and failures. These are very valuable materials. From the perspective of the development of the entire application system, lessons should be more than experience. This is very important for Chinese insurance companies. The further development of the management system has a strong reference. Especially in terms of organizational management experience. Therefore, it is very necessary for us to learn the management methods of foreign companies. As the saying goes - take the essence and discard the dross. Learn from their good aspects, and at the same time get rid of some of their bad ones. A good thing is worth learning. Learning excellent foreign insurance management mechanisms can make our domestic insurance industry develop even better. A good dividend mechanism can promote us to become better. Compared with the domestic software industry, the foreign software industry developed earlier, so their systems are relatively more complete, so we need to learn from their excellent management systems in order to make our insurance industry grow stronger .

Significance

As we all know, no matter what company wants to develop, it depends on certain technologies and knowledge to varying degrees in order to develop and survive better. Especially in today's era of knowledge economy and information economy, the competition between enterprises now lies more in the competition of knowledge acquisition and information acquisition and use capabilities. Therefore, the effective management and timely acquisition of information resources for enterprises are the prerequisites for better development in today's era. Only by taking effective measures in information processing, can the company remain invincible in the fierce competition for a long time. Regardless of any industry, an excellent management mechanism is needed, so that the company can develop more perfectly. As the old saying goes: To do a good job, you must first sharpen your tools. This is a sufficient representation. If a good company wants to stand out in a load environment, it must have an excellent management system. Now that Internet technology has developed very rapidly, it is particularly necessary to establish a management system that can It is a system on the web browser to manage the company's insurance business, so our system came into being.

Through this system, the management of insurance business can be made more convenient. Users and managers can more conveniently purchase insurance and manage business through the management system, which is much more convenient than traditional manual management. Provide convenience for managers. And the system runs stably, and the data is safe and reliable. In modern management, computer systems have become an indispensable helper for enterprise management. Its wide application has become an important symbol of modern management. Facing more and more information resources and complex enterprise environment, it is believed that it is necessary for enterprises to create an efficient and practical information management system. This is the inevitable trend of modern management. Therefore, it is necessary to develop a management system for business management of the enterprise.

The development purpose of the insurance management system is to change the management mode of insurance business from manual recording to information management, and provide convenient conditions for managers. After investigating the actual situation of the insurance business, conduct a detailed demand analysis, improve the existing management model, develop a new management system, understand the idea of ​​system development, and master the process and methods of system development. The advantages of developing this management information system are mainly reflected in that it has greatly improved the work efficiency of the insurance company's staff, and greatly reduced the disadvantages of cumbersome, messy and long-term deposit and exit procedures in the past. With the help of the computer system's unique mechanism such as the rigor of data processing, the insurance business management system has played a good role in improving the data management method of insurance business, reducing the labor intensity of business personnel, and improving labor productivity. At the same time, it can also make the business process more standardized, the processing of information and data more efficient and accurate, can adapt to the requirements of informatization, and can help staff use computers to quickly and conveniently manage, input, output, and search information and data flows. Need to operate, so that the messy business data can be concretized, visualized, rationalized, etc.

The practical significance of the implementation of the insurance business system:

The system handles business more efficiently and saves human resources.

Comprehensive setting of basic information, convenient and fast data entry.

It maximizes the ease of maintenance and operability.

The system runs stably and the data is safe and reliable.

The main purpose of this system is to develop an insurance management system that is easy to operate, fast to use, and efficient to handle. Therefore, this system is prone to errors, cumbersome process, low work efficiency and poor confidentiality due to manual operation, which has certain restrictions on the operability, stability and practicability of the system, and can safely store data in database to increase the confidentiality of its system. Make it truly safe, standardized, scientific and informatized in the insurance management system. Ultimately enabling companies to better manage their insurance operations. This system is prone to errors, cumbersome process, low work efficiency and poor confidentiality due to manual operation, which has certain restrictions on the operability, stability and practicability of the system, and can safely save data in the database. To increase the security of its system. Make it truly safe, standardized, scientific and informatized in the insurance management system.

System Development Technology

  1. system development tools
  2. Jsp technology

JSP technology is the main technology for developing Java Web applications. The full name is java server page, which is basically a simplified Servlet design. It was developed by Sun Microsystems in 1996 and is a dynamic web technology standard established with many companies. JSP is an extension of servlet technology, and the current version is 1.2 (version 2.0 will be finalized soon). Some people think that JSP is a replacement for servlets, but that is not the case. Servlets and JSP are used together for complex web applications.

JSP technology is somewhat similar to ASP technology. It inserts Java program segments (Scriptlet) and JSP tags (tag) into traditional web page HTML files (*.htm, *.html) to form JSP files (*.jsp), and The program fragments of the formed JSP webpage can control the database, redirect the webpage and send E-mail, etc., so as to meet the functions required for establishing a dynamic website. Simply put, JSP can be expressed as: HTML+Java=JSP. The operating principle of JSP technology is that all JSP pages will be converted into Servelet (. class), and is interpreted and executed by the Java Virtual Machine (JVM). The main reason for using JSP technology is that it does not have high requirements for the client's browser because all operations are performed on the server side, and the client only receives the transmission result. Even if the client's browser does not support Java, it can also access the JSP web page. If the Web application is developed with JSP, it can be used across platforms and can run on Linux and other operating systems.

JSP technology uses Java language to write class tags to encapsulate the processing logic of web pages, and uses Java programming language to write XML-like tags and scriptlets to encapsulate the processing logic of generating dynamic web pages. JSP separates webpage logic from design display, supports reusable component-based design, and makes web-based program development simple and easy. The web page supported by JSP (Java Server Pages) technology is dynamic, which separates the logic from the servlet.

The reason why this system uses JSP technology is also based on the fact that JSP has many advantages compared to other technologies:

JSP code is cross-platform, that is, write once and run everywhere

As we all know, Microsoft's products are all monopolistic, and their portability is poor, and ASP is no exception. In comparison, JSP avoids these problems and can be used on many platforms, which is more civilian and humane. .

JSP components cross-platform

JSP components include enterprise JavaBeans, JavaBeans or custom JSP tags, which are reusable across platforms just like code. Enterprise JavaBeans components can access traditional databases and work in a distributed system mode on Solaris, Linux, UNIX and Windows platforms.

Supports multiple web formats

At present, there is no specific standard for the web page format supported by JSP technology. Generally speaking, JSP technology can not only support the traditional browser file format of HTML/DHTML, but also apply to the WML file format for wireless communication devices such as mobile phones, PDAs and other devices for web page preview, and can also support some other B2B e-commerce websites. The XML format of the application.

JSP tag extensibility

JSP tag technology is compatible with XML, so the creators who develop web pages can make full use of this technology to reduce the dependence on scripting language, making web page construction easier and easier.

Robustness and Security

The storage management of the Java language is robust and has higher security, while JSP makes web pages based on the Java language, so it also includes the advantages of the Java language.

SSH technical overview

"SSH Combination Framework" is the abbreviation of Struts + Spring + Hibernate. "SSH Combination Framework" embodies the teamwork spirit of "joining forces, each performing its own duties, and coordinating and complementing each other". The process of the SSH framework is roughly: Jsp page----Struts------Service (business logic processing class)---Hibernate (left to right). The Struts framework responsible for controlling the Service life cycle will increase the dependency between layers, which is commonly referred to as coupling. The development of large-scale Java Web applications has the disadvantages of cumbersome code, difficult maintenance and expansion, and the "SSH composition framework" can well realize business layering and provide a good solution platform for this problem. 1

1、Struts

The earliest Java Web programs were all implemented using JSP. JSP pages contained HTML tags and Java business logic codes, which made the entire JSP page too cumbersome and difficult to maintain. When a problem occurred in the system, developers were helpless in the face of a large number of codes. So SUN company standardized the Java Web, first launched mode 1, introduced JavaBean code in mode 1, in order to achieve the purpose of encapsulating business logic code, and finally successfully separated the logic code from JSP pages, and mode 1 introduced The JavaBean code still has defects in process control. Therefore, the introduction of Servlet technology in Mode 2 completely separates the entire framework into three parts: model, window and controller, making Java Web application development more standardized. Later, Mode 2 was launched, and Struts 2 combined the multiple advantages of components, and also made the development of MVC-based Java Web applications easier. Struts 2 follows a certain pattern through the core controller Struts Prepare And Execute Filter (the core filter of struts2.0.x to 2.1.2 is FilterDispatcher, which has been changed to truts Prepare And Execute Filter since version 2.1.3) and interceptors Better realize multiple functions such as background control and maintenance, front-end performance and business logic processing.

Struts is used as the application layer, which is responsible for calling the business logic serivce layer, thus controlling the life cycle of the Service.

2、Spring

Server manufacturers do not unify many technical supports, so J2EE applications lack platform independence, and the efficiency of application development is low, and Struts calls logical services will lead to increased dependencies between layers, resulting in coupling problems. At this time, the Spring framework, as an open source middleware, plays a linking role. It controls the Action object (in Strus) and the Service class, making the relationship between the two loose, reducing the dependency between layers to achieve loosening The purpose of coupling, this is the role of Spring's Ioc mechanism (inversion of control and dependency injection).

In fact, Spring acts as a management container to manage the work between struts and hibernate. As a manager, it acts as a bridge in the entire program. The entire program needs to run through this bridge. Spring is committed to solving various application problems. Layer schemes, not just limited to one layer.

It can be said that Spring's "one-stop" function runs through the presentation layer, business layer and persistence layer. But Spring does not replace the entire framework but fits perfectly with it, just like a server rather than a leader occupying the entire field. The core technology of Spring is the inversion of control IOC and AOP proxy mechanism. Now Spring uses basic JavaBean to solve things that can only be done by EJB before. The use of Spring is not limited to the server side. From many perspectives, any Any Java application can benefit from Spring.

3、Hibernate

Now there is a shortcoming in the development of many multi-tier architectures. It is very difficult to separate the persistence layer by using JDBC alone. Programmers responsible for writing business logic codes need to write a large number of SQL statements when interacting with the database. Pay attention to the structural relationship of each table in the database to ensure that its SQL statements work normally. The introduction of persistence layer middleware such as Hibernate makes a good encapsulation of JDBC. The developers of the business logic layer are faced with objects and do not need to care about data tables. This is conducive to division of labor and cooperation, and reduces product reliability. portability. Hibernate can be introduced in any occasion where JDBC is used, either in Java Application or in Servlet/JSP Web application.

4. Integration

The Struts 2 tag library handles the view layer, the core controller and business control of Struts 2 act as the control layer, Hibernate and various business logic components handle business layer affairs, and finally Spring manages the Bean resources, and performs unified management and integration of the JavaBean instance resources of the entire application. scheduling. The three open source frameworks complement each other and run well on all resources, just like the division of labor and cooperation of a team with clear tasks, so the introduction of the "SSH framework" promotes the development of J2EE.

Introduction to B/S mode

HTTP

B/S (Browser/Server, browser/server) mode is also called B/S structure. It is an extension of the C/S mode application with the rise of internet technology. Under this structure, the user interface is realized through the browser. The biggest advantage of the B/S mode is that it is relatively easy to operate and maintain, and it can enable different personnel to access and operate common data analysis from different locations with different access methods (such as LAN, WAN, Internet/Intranet, etc.). The B/S mode is shown in Figure 2-1

database

Oracle

web server

Browser browser

HTML

2-2 B/S mode diagram

  1. System development environment
  2. MySQL database
    The operation of any program requires a database, which is an indispensable part of the network development process. Just like any creature, regardless of its size or size, the continuation of its life needs the beating of the heart. The same reason, no matter the size of the program, Both require database support. Web databases generally have a three-tier or multi-tier architecture. The front end uses browser technology to access the database through middleware and servers.
    MySQL software currently belongs to Oracle Corporation and is developed by MySQL AB of Sweden. In the past, databases stored data in one space, just like a large warehouse, so it was easy to cause too much redundant and complicated data and difficult to manage. MySQL is a relational database management system, which stores data in different tables in blocks. Among them, the flexibility of data is improved and the problem of slow running speed caused by redundant data is also solved.
    Due to its small size, fast speed, and low overall cost of ownership, MySQL software has become a common network database for small and medium-sized website development, especially the open source feature. The SQL language used to access databases is very common, making many companies prefer to use Select the MySQL database. MySQL software is divided into community edition and commercial edition. Due to the excellent performance of its community edition, it can form a good development environment with PHP and Apache.
    The shortcomings of MySQL's small scale and limited functions (MySQL Cluster's functions and efficiency are relatively poor) cannot keep pace with other large databases such as Oracle, DB2, SQL Server, etc., but it does not dampen the enthusiasm of many small and medium-sized websites for using it. "Although the sparrow is small, it has all the internal organs." The functions provided by MySQL are sufficient for general individual users and small and medium-sized enterprises, and the open source code greatly reduces the total cost of ownership, making it more popular with these users.
  3. MyEclipse IDETools

MyEclipse Enterprise Workbench (MyEclipse Enterprise Workbench, referred to as MyEclipse) is an extension of EclipseIDE, and we can use it to greatly improve work efficiency in the development and release of databases and JavaEE, as well as the integration of application servers. It is a feature-rich JavaEE integrated development environment, including complete coding, debugging, testing and publishing functions, and fully supports HTML, Struts, JSP, CSS, Javascript, Spring, SQL, Hibernate.

MyEclipse is a very good collection of Eclipse plug-ins for developing Java and J2EE. MyEclipse has very powerful functions and extensive support, especially for various open source products. MyEclipse currently supports Java Servlet, AJAX, JSP, JSF, Struts, Spring, Hibernate, EJB3, JDBC database link tools and many other functions. It can be said that MyEclipse almost includes the exclusive eclipse development tools of all current mainstream open source products.

system analysis

  1. Feasibility Analysis

Feasibility analysis is an indispensable work in current project development and has decisive significance. Before a project starts, it is necessary to conduct a comprehensive and scientific analysis of the project, conduct scientific research from various angles, and conduct a comprehensive analysis of your own project. This project is mainly about technical feasibility, economic feasibility, management feasibility and social feasibility.

Feasibility analysis is to carry out specific, in-depth and detailed technical demonstration and economic evaluation on the possibility, effectiveness, technical plan and technical policy of the project before formulating a certain construction or scientific research project, in order to determine a technically advanced project. Reasonable, economically cost-effective optimal solution and written report written for the best time.


  The main content of the feasibility study report is to use comprehensive and systematic analysis as the main method, economic benefits as the core, and use a large amount of data to demonstrate whether the proposed project is feasible around various factors that affect the project. Provide a comprehensive analysis and evaluation of the entire feasibility study, pointing out the advantages and disadvantages and suggestions.

  1. technical feasibility

The development tool of this management software is Myeclipse, the front page uses JSP technology, and the background database is MySQL.

The software system is implemented using the SSH framework, which has many advantages. SSH is a typical J2EE three-tier architecture that embodies the idea of ​​MVC, which divides an application into three basic parts: M (model), V (view) and C (controller). Over there and quickly develop new requirements and reduce development costs. It also has good scalability, and SSH also has good maintainability. Using this framework realizes the complete separation of view, controller and model, and can separate the business logic layer from the persistence layer.

It can greatly improve the reusability. In this case, no matter how the front end changes, the model layer only needs a small change. And the front end will not change with the database. Also because the coupling between different layers is small, it can facilitate work and greatly improve efficiency. The control layer depends on the business logic layer and is only coupled with the interface, but never coupled with any specific business logic components; similarly, the business logic layer depends on the DAO layer, and will not be coupled with any specific DAO components, but is interface-oriented programming. Software implemented in this way, even if some parts of the software change, other parts will not change.

By using the SSH framework and connecting to the database, each module in this system can be well realized. So it is technically feasible.

economic feasibility

From the perspective of economic feasibility, the main considerations in the software system development process are how to save costs to the greatest extent, shorten the software development cycle, and obtain the maximum return with the minimum investment. The realization of the software is based on the B/S architecture, which is the browser and server structure. Under this structure, the user's working interface is realized through the browser. All operations of this management software are based on the WEB browser, and rarely The business logic is implemented on the front end, and basically the main things are implemented on the server side, which greatly simplifies the client computer load, reduces the overall cost of users, reduces the cost and workload of system maintenance and upgrades, and develops The software used is directly installed on the machine, so the cost is low and the efficiency is high, without too much financial burden. Therefore, it is also economically feasible.

management feasibility

The system has two roles: administrator and customer. Customers can log in to their user accounts to place orders, apply for compensation or modify their information. However, the administrator can directly manage customer information by logging in as the administrator user, and can view all order information and compensation information, which plays the role of supervision and review, and plays a role in supervision and management. Therefore, it is feasible in management. Management feasibility is very useful. With a good management feasibility, the runtime of the system is very good, which is very helpful to the completion of the system.

social feasibility

The current Chinese insurance market is a rapidly developing and changing market. Insurance industry IT services must meet the requirements of this status quo. Therefore, they have higher requirements for the response speed and service quality of IT services.

At this stage, many factors of my country's economic environment have put forward new requirements for the insurance industry. On the one hand, after joining the WTO, the joining of foreign insurance companies will have a significant impact on my country's insurance industry, and the Chinese insurance market will show international characteristics, which is conducive to business expansion; Faced with severe tests, higher requirements are placed on the company's operating capabilities.

Now, the characteristics of the insurance industry determine that enterprise management information is particularly important to insurance companies. The company's business strategy, business operations, financial management, analysis and decision-making are all based on high-quality information management. Various insurance companies have increasingly strong requirements for the development of new insurance types, business management, their own risk management and control, and service level improvement, which requires their core business systems not only to simply support the business, but more importantly, to achieve support , analysis, management, and decision-making levels. In other words, the quality of insurance information system will fundamentally affect the core competitiveness of insurance companies.

operational feasibility

With the continuous development of society and the continuous popularization of computers, more and more people have been able to master the basic operations of computers proficiently. This system adopts a Windows-based graphical user interface and can be operated through a web browser. It is an operating system that everyone is familiar with, and it can be easily used by those with general computer knowledge. The entire policy management system adopts a friendly interactive interface, which is concise and clear. It can be easily used without an in-depth understanding of the database, and there is no need to train the personnel who use the system. This not only reduces the input cost but also simplifies the operation link.

  1. demand analysis

Software requirements analysis is a very important part of software project design. In the long history of software engineering, people have regarded requirements analysis as a very simple step in the whole software engineering for a long time, but in the past ten years or so, more and more people have gradually realized that it is the whole process one of the most critical processes. Only through software requirements analysis, can the overall concept of software functions and performance be described as specific software requirements specifications, thereby laying the foundation for software development. The failure of many large-scale application systems is ultimately attributed to the failure of requirements analysis: either the method of obtaining requirements is improper, which makes the requirements analysis incomplete or incomplete, causing developers to repeatedly conduct requirements analysis, resulting in design, coding, and testing. It goes smoothly; or the customer does not cooperate well, causing the customer to not confirm the demand, or the customer's demand is constantly changing, which also makes the design, coding, and testing unable to proceed smoothly.

The reason why requirements analysis is important is because it has decision-making, directional, and strategic functions. It plays a pivotal role in the process of software development. Everyone must pay enough attention to requirements analysis. In a large software system In development, his role is far greater than that of programming. Requirements analysis is very important in a project. A good project is inseparable from requirements analysis. The quality of requirements analysis is an important guarantee for the success of a project. Therefore, the completion of a project must do a good job in requirements analysis. Only after understanding the requirements can we better set the business logic. This is a top priority for project completion. We need to complete the needs analysis well. The quality of requirements is an important guarantee for the completion of a design. If the demand analysis is not done well, there will be many problems in the follow-up work, and rework will be required, resulting in a decline in efficiency, so it is necessary for us to improve the demand.

The insurance business information management system is mainly to complete the process of placing insurance orders, paying fees, applying for compensation, and managing personal information. It can be divided into a client part and an administrator part.

  1. customer part

Customers mainly register their own users, log in to the system through their own user accounts, and then view various insurance information, select the type of insurance they want to purchase, place an order, and apply for compensation after an accident occurs You can also enter your own personal user interface to modify your personal information.

The needs of the customer part can be divided into the following four parts in total:

View/purchase insurance product information, view/confirm order information, view/apply for compensation information, and manage personal information.

(1) View/purchase insurance product information

Customers can see the insurance information currently sold: insurance name, insurance cost, release time, insurance content, and after selecting the appropriate insurance, they can add it to the order.

(2) View/confirm order information

After selecting the insurance to be purchased, the customer can view the order name, order amount, order time, orderer, and order status in the order list, and confirm the order after making a decision.

(3) View/apply for compensation information

Customers can manage the personal compensation application list on the personal compensation information management interface. Customers can apply for compensation when the insurance content takes effect after purchasing the insurance.

(4) Management of personal information

Customers manage personal registration information through the personal information management panel: account name, password, name, age, phone number, contact address, and customers can modify their own information in personal information.

administrator section

After logging in through the administrator user, the administrator can manage various insurance information under the company's insurance list, including adding and deleting operations, and can also check the user's order purchase status, whether the payment has been completed, and can also make compensation In the management of information, you can choose to agree or disagree with the compensation applied by the user, and finally you can also perform user management operations, add or delete users. Administrator users can manage users at will, which is of great help to user management.

The needs of the administrator can be divided into the following four parts: insurance information management, order information management, compensation information management, user information management.

(1) Insurance information management

After the administrator logs in his own administrator user, he can add or delete the insurance information management through the background, so as to complete his own insurance information management.

(2) Order information management

After the administrator logs in and enters the order management interface, he can view all the order information submitted by the current user.

(3) Compensation information management

The administrator can view the compensation application submitted by the user, and agree or disagree with the user's compensation application according to the actual situation.

(4) User information management

Administrators can maintain all customer information in User Information Management. Including adding and deleting users, and managing user information.

Overall System Design

  1. System design
    SSH is an integrated framework of struts+spring+hibernate, which is a popular open source framework for Web applications. Ssh architecture diagram, as shown in Figure 4-2


4-1 ssh architecture diagram
The system is divided into three layers: presentation layer, business layer, and persistence layer.
In the presentation layer, first implement the interactive interface through the JSP page, responsible for receiving the request (Request) and transmitting the response (Response), and then Struts delegates the Request received by ActionServlet to the corresponding Action according to the configuration file (struts-config.xml) .
In the business layer, the Spring IoC container that manages the service components is responsible for providing the Action with the business model (Model) component and the component's collaborative object data processing (DAO) component to complete the business logic, and provides container components such as transaction processing and buffer pool to improve system performance and ensure data integrity.
In the persistence layer, it relies on Hibernate's object mapping and database interaction to process the data requested by the DAO component and return the processing result.
Struts is responsible for the Web layer:
ActionFormBean receives the data submitted by the form in the web page, then processes it through Action, and then forwards to the corresponding web page. <action-mapping> is defined in Struts-config.xml, and ActionServlet will be loaded in.
Spring is responsible for business layer management, that is, Service:
Service provides a unified call interface for Action, encapsulates the DAO of the persistence layer, and integrates Hibernate. Spring can perform unified management of JavaBean and things.
Hibernate is responsible for the persistence layer and completes the CRUD operations of the database:
Hibernate has a set of hbm.xml files and POs, which correspond to the tables in the database, and then defines DAOs, which are classes that deal with the database.
In the Struts+Spring+Hibernate system, the calling process between objects is shown in Figure 4-2:


4-2 Flowchart
  Struts——>Spring—>Hibernate
  JSP——>Action—>Service—>DAO——>Hibernate

  1. System structure design

Regarding the research on insurance business information management, I chose to use the SSH framework to write and use mysql as the database to design the insurance business management system. This system is mainly divided into two parts: insurance business management and background management. Insurance business management can be viewed/purchased Insurance product information, view/confirm order information, view/apply for compensation information, manage personal information. The background management part is mainly for the administrator to log in to the administrator user for management, and the authority of the administrator can be divided into insurance information management, order information management, compensation information management, and user information management. The specific functional structure diagram is shown in Figure 4-3.

4-3 Function structure diagram

  1. Database relationship diagram
    ER diagram, also known as entity-relationship diagram (Entity Relationship Diagram), provides a way to represent entity types, attributes and connections, and is used to describe the conceptual model of the real world. For any database, any number of database diagrams can be created; each database table can appear in any number of diagrams. In this way, different diagrams can be created to visualize different parts of the database, or to emphasize different aspects of the design. For example, you can create a large relationship diagram that shows all tables and columns, and a smaller relationship diagram that shows all tables but no columns. The ER diagram of the system is shown in Figure 4-3.


4-3 System ER Diagram
Through the database relationship diagram, we can see the relationship between tables, which can be mainly divided into user_list, order_list and product_list. The items contained in each table are shown in the figure below

  1. System Use Case Diagram

The use case diagram is a diagram used to show what the designed system can be used for. The use case mainly focuses on the external performance of the system, the interaction between people, and the interaction between people and the system, the system and other systems interaction.

There are three basic elements in a use case diagram: use case, relationship, role

Actor: It is used to describe the roles in the system. Different roles occupy different system functions, and each villain in the use case diagram is the represented role.

Use Case: A use case is a description of a sequence of actions, including variables, that a system performs to produce observable results that deliver value to a particular actor. A use case is represented by an elliptical circle in the use case diagram, and the sequence is described by words in the circle, generally described by a verb object.

Relationship: It is used to describe the relationship between roles and lines, and is represented by lines in the use case diagram.

Lines refer to the lines between roles and use cases. These lines are used to connect roles (villains) and use cases (circles), indicating what use cases a certain role can "do".

Administrator Use Case Diagram

The authority of the administrator in the entire management system mainly includes insurance information management, order information management, compensation information management, and user management. Among them, insurance information management mainly includes viewing new insurance information and deleting insurance information, order information management includes viewing order information, compensation information management includes approving compensation applications, and user management mainly includes viewing new users and deleting users. 4-4

4-4 Administrator Use Case Diagram

Client's use case diagram:

Customers are the most important resource in an insurance company. After logging in to their main business, customers can perform their own relevant authority operations. The authority is mainly divided into four modules: insurance information, order information, compensation information and personal information management. Insurance information includes purchasing insurance products, and order information includes confirming and canceling orders. Information, compensation information module mainly includes compensation application, personal information management module users can modify and save their own personal information. The use case diagram of the customer participating in the entire system is shown in the figure:

4-5 Customer Use Case Diagram

System detailed design and implementation

  1. System detailed design

There are 3 data dictionaries in the insurance business management system design, namely: user information table (user_list), feedback evaluation information table (product_list), software information table (order_list). There are different structures under the three tables.

From the perspective of ordinary users, the logical relationship model of data is a simple two-dimensional table, and each table stores the logic of the overall business in the insurance company. The main entities and their attributes involved in the management system are as follows:

  1. Database structure design
    User information table: user_list (primary key, account number, password, name, gender, age, telephone, address, type) feedback
    evaluation information table: product_list (primary key, product name, product content, product cost, release time)
    software information Table: order_list (primary key, order name, order amount, order time, orderer, orderer ID, order status, product ID)
  2. Data Dictionary

A data dictionary is a collection of descriptions of data objects or items in a data model for the benefit of programmers and others who need to refer to them. The first step in analyzing a system of objects exchanged by users is to identify each object and its relationship to other objects. This process is called data modeling and results in an object-relational diagram. After each data object and item has been given a descriptive name, its relationship is described (or becomes part of a structure that potentially describes the relationship), and then the type of data (such as text or image, or a binary value), lists all possible predefined values, and provides a simple textual description.

There are three data dictionaries in the insurance business management system design, namely:

Table 1 user_list table

attribute name storage code type of data length Remark
primary key user_id int 11 primary key, unique
username username varchar 45
password password varchar 45
Name name varchar 45
gender sex varchar 45
age age varchar 45
Telephone phone varchar 45
address address varchar 45
type type varchar 45

The user information table mainly includes the user's personal information, including username (username), password (password), name (name), gender (sex), age (age), phone (phone), address (address) and type ( type) several parts.

Table 2 product_list table

attribute name storage code type of data length Remark
primary key product_id int 11 primary key, unique
product name product_name varchar 100
product content product_desc varchar 2000
product cost product_cost varchar 45
release time product_time varchar 45

The feedback evaluation information table contains detailed description information of the insurance type, mainly the insurance policy number. Among them, product name (product_name), product content (product_desc), product cost (product_cost), release time (product_time). It is mainly used to feedback product information. This table contains all insurance business information and is used to save insurance products. The information contained in it is the various contents of the insurance product.

Table 3 order_list table

attribute name storage code type of data length Remark
primary key order_id int 11 primary key, unique
order name order_name varchar 100
order amount order_cost varchar 45
order time order_time varchar 45
order person order_uname varchar 45
Order ID order_uid varchar 45
Order Status order_state varchar 45
Product ID product_id varchar 45

The software information table mainly includes the user's order information, which includes the order name (order_name), order amount (order_cost), order time (order_time), orderer (order_uname), orderer ID (order_uid), order status (order_state), product ID (product_id). This information is of vital importance to the user. The status of the user after placing an order is displayed in this table. This represents the core of the entire system, and all business implementations are basically in this table, so this table is very important.

  1. module implementation
  2. Login module
    All users can log in to the system with correct information after entering their account numbers and passwords. As shown in Figure 5-1


5-1 Login interface

If you enter the administrator interface through the administrator account, as shown in Figure 5-2


5-2 Administrator interface
Log in with the user account to enter the user interface, as shown in Figure 5-3


5-3用户界面
不同身份,功能的权限也不同。
登录所需代码:
public String login(){
UserList ul = userListService.login(userlist.getUsername(), userlist.getPassword(), "");
if (ul.getUser_id() != 0) {
session.put("login", ul);
return SUCCESS;
}else{
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");//防止弹出的信息出现乱码
try {
PrintWriter out = response.getWriter();
out.print("<script>alert('用户名或密码错误!')</script>");
out.print("<script>window.location.href='http://localhost:8080/InsuranceBusiness/Login.jsp'</script>");
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}

  1. 保险信息模块
    管理员登录进去所显示的界面,如图5-4所示


5-4管理员界面
管理员可以在保险信息管理中查询、新增或者删除保险产品信息。如图5-5所示


5-5 增加保险界面
客户可以在保险列表中查看所有保险产品。如图5-6所示


5-6 用户查看保险信息
客户选择需要购买的保险后,加入订单信息中,用户可以在订单中确认或取消订单。如图5-7所示


5-7 用户个人订单列表

public List<ProductList> selProductList() {
Session session = sessionFactory.openSession();
String sql="select * from product_list";
Transaction tran = session.beginTransaction();
SQLQuery sq = session.createSQLQuery(sql);
List<Object[]> list = sq.list();
List<ProductList> plist = new ArrayList<ProductList>();
for(Object[] obj : list){
ProductList pl = new ProductList();
pl.setProduct_id((Integer)obj[0]);
pl.setProduct_name((String)obj[1]);
pl.setProduct_desc((String)obj[2]);
pl.setProduct_cost((String)obj[3]);
pl.setProduct_time((String)obj[4]);
plist.add(pl);
}
tran.commit();
session.close();
return plist;
}
}

  1. 赔偿模块
    客户确认购买保险后,可以申请赔偿。如图5-8所示


5-8 个人用户赔偿列表
管理员可以根据实际情况同意或者否决用户的赔偿申请,如图5-9所示。


5-9管理员赔偿管理列表
public List<OrderList> selOrderList(String uid, String state) {
Session session = sessionFactory.openSession();
String sql="select * from order_list where order_uid = '"+uid+"' and order_state in ("+state+")";
Transaction tran = session.beginTransaction();
SQLQuery sq = session.createSQLQuery(sql);
List<Object[]> list = sq.list();
List<OrderList> olist = new ArrayList<OrderList>();
for(Object[] obj : list){
OrderList ol = new OrderList();
ol.setOrder_id((Integer)obj[0]);
ol.setOrder_name((String)obj[1]);
ol.setOrder_cost((String)obj[2]);
ol.setOrder_time((String)obj[3]);
ol.setOrder_uname((String)obj[4]);
ol.setOrder_uid((String)obj[5]);
ol.setOrder_state((String)obj[6]);
ol.setProduct_id((String)obj[7]);
olist.add(ol);
}
tran.commit();
session.close();
return olist;
}
public String selCompensateListByMe(){
UserList ul = (UserList)session.get("login");
List<OrderList> clist = orderListService.selOrderList(String.valueOf(ul.getUser_id()), "'1','2','n','9'");
session.put("clist", clist);
return SUCCESS;
}

  1. 用户信息模块
    管理员登录管理员账号后,用户管理界面,如图5-10所示。


5-10管理员用户管理界面
管理员可以修改用户的个人信息,如图5-11所示


5-11管理员修改用户信息界面

客户可以在个人信息管理中修改自己的信息,如图5-12所示


5-12客户修改个人信息界面
增加更新用户
public UserList selUser(String uid) {
Session session = sessionFactory.openSession();
String sql="select * from user_list where user_id = '"+uid+"'";
Transaction tran = session.beginTransaction();
SQLQuery sq = session.createSQLQuery(sql);
List<Object[]> list = sq.list();
UserList ul = new UserList();
for(Object[] obj : list){
ul.setUser_id((Integer)obj[0]);
ul.setUsername((String)obj[1]);
ul.setPassword((String)obj[2]);
ul.setName((String)obj[3]);
ul.setSex((String)obj[4]);
ul.setAge((String)obj[5]);
ul.setPhone((String)obj[6]);
ul.setAddress((String)obj[7]);
ul.setType((String)obj[8]);
}
tran.commit();
session.close();
return ul;
}
public void updateUser(UserList ul) {
Session session = sessionFactory.openSession();
Transaction tran = session.beginTransaction();
String sql = "update user_list set password = '"+ul.getPassword()+"', name = '"+ul.getName()+"', sex = '"+ul.getSex()+"', age = '"+ul.getAge()+"', phone = '"+ul.getPhone()+"', address = '"+ul.getAddress()+"', type = '"+ul.getType()+"' where user_id = '"+ul.getUser_id()+"'";
session.createSQLQuery(sql).executeUpdate();
tran.commit();
session.close();
系统测试
经过分析、设计和编码等阶段的开发后,得到了源程序,开始进入到软件测试阶段。然而,在测试之前的各阶段中都可能遗留下许多错误和缺陷,如果不及时找出并改正,这个软件产品就可能会导致巨大的损失。目前,程序的正确性证明尚未得到根本的解决,因此软件测试仍是发现软件中错误和缺陷的主要手段。
系统测试,就是将已经确认的软件、计算机硬件、外设、网络等其他元素结合在一起,进行信息系统的各种组装测试和确认测试。系统测试是针对整个产品系统进行的测试,目的是验证系统是否满足了需求规格的定义,找出与需求规格不符或与之矛盾的地方,从而提出更加完善的方案。系统测试发现问题之后要经过调试找出错误原因和位置,然后进行改正,是基于系统整体需求说明书的黑盒类测试,应复盖系统所有联合的部件。对象不仅仅包括需测试的软件,还要包含软件所依赖的硬件、外设甚至包括某些数据、某些支持软件及其接口等。比较常见的、典型的系统测试包括恢复测试、安全测试、压力测试。
软件测试方法从测试人员角度看,可分为人工测试和机器测试。人工测试又称为代码复审。主要有三种方法:个人复查、走查、会审。机器测试分为黑盒测试(又称功能测试)和白盒测试(又称结构测试)两种。
下面对本系统进行测试,以检查系统能否正确完成各种操作,是否能够实现预期具有的功能。
登录测试,如图6-1所示


6-1登录测试
管理员测试:
赔偿信息管理测试,如图6-2所示


6-2赔偿信息管理测试
赔付成功如图6-3所示


6-3赔付测试
用户管理测试:
测试要点:新增用户 。
测试路径:填写的用户信息是否完整。
测试结果:填写完整,系统增加新的用户信息;填写不完整,提示输入完整的用户信息。如图6-4所示


6-4增加用户测试
修改用户信息,如图6-5所示。


6-5修改用户信息测试
删除用户,如图6-6所示


6-6删除用户测试
保险信息管理测试,如图6-7所示


6-7管理员保险信息管理测试
新增保险,如图6-8所示。


6-8新增保险测试
删除保险产品如图6-9所示。


6-9删除保险测试
订单信息管理测试,如图6-10所示。


6-10订单信息管理测试
客户:
保险信息管理测试,如图6-11所示。


6-11用户保险管理测试
购买如图6-12测试


6-12保险购买测试
赔偿信息测试,如图6-13所示。


6-13赔偿信息测试
个人信息测试,如图6-14所示。


6-14个人信息测试
参考文献
[1]温涛.东软Java软件工程师实训项目教程;大连;东软电子出版社,2011.8
[2]2016-2017年中国保险行业发展现状、发展趋势、发展前景分析
http://www.chyxx.com/industry/201611/471965.html
[3]伍飞.冉文江.基于J2EE架构的SSH框架研究及应用[J];信息系统工程;2010.6
[4]单晓光.Java Web开发技术的教学方法研究[J];黑龙江教育学院学报;2011.7
[5]刘志成.Java程序设计实例教程;北京;人民邮电出版社;2010.8
[6]李刚.Struts2权威指南——基于WebWork核心的MVC开发[M].北京:电子工业出版社,2007.
[7]鲁霞.基于Struts_Spring_Hibernate架构的综合积分系统的研究与实现[D].成都:西南交通大学硕士学位论文,2008.
[8]赵少卡.基于Struts+Spring+Hibernate架构的信息交流平台的设计与实现[J].计算机与现代化,2009(2):62-66.
[9]黄志明.基于Spring+Struts+Hibernate的报备系统的设计与实现[J].电脑知识与技术,2008,4(Z2):40-41.
[10]MySQL入门与精通教程
http://www.docin.com/p-167853642.html
[11]网络数据库Mysql介绍
http://www.docin.com/p-60867610.html
[12]曹大有.基于Struts和Spring框架技术的Web应用的开发过程[J].计算机应用与软件,2008,25(8):203-204.
[13]夏昕.曹晓钢.深入浅出Hibernate[M]. 北京:电子工业出版社,2005.
[14]夏昕.Spring开发指南[M].北京:电子工业出版社,2004.
[15]O‘REILLY. Learning MySQL.2010
[16]DEITEL Java How to Program, 2012
[17]O‘REILLY JavaServer Pages (JSP) - From The O´Reilly Anthology, 2011
[18]陈潇.在SQL Server使用触发器实现数据完整性[J].电脑知识与技术,2013(35)
[19]姜锋.Web网站通信安全的优化方案[J].网络安全技术与应用,2015,(10):53,55.DOI:10.3969/j.issn.1009-6833.2015.10.035.
[20]杨荻.保险行业BS架构信息管理系统设计与应用[J].计算机仿真,2010,27(6):342-345.DOI:10.3969/j.issn.1006-9348.2010.06.082.
[21]马秀麟,衷克定,刘立超等.从大数据挖掘的视角分析学生评教的有效性[J].中国电化教育,2014,(10):78-84.DOI:10.3969/j.issn.1006-9860.2014.10.013.
[22]杨伟斌.tomcat安装配置在高校web课堂中的应用研究[J].速读(下旬),2015,(9):309-309.
致谢
感谢XX理工大学对我四年来的栽培,通过大学四年的学习,我的专业知识得到了飞速的增长,眼界得到了开阔,没有学校对我的亲切栽培,就没有我的今天,非常感谢学院给我提供了优美的校园环境,舒适整洁的宿舍环境,感谢老师们对我无微不至的指导,让我学到了很多有用的专业知识,也要感谢自己的同学、舍友们为自己创建了一个良好的学习生活氛围,大家们都来自五湖四海,从遥远的家来到这个地方一起生活一起学习,四年里几乎没有为琐事吵过架和红过脸,在互相遇到困难的时候都积极帮助,就像一家人一样,眼看毕业,大家都要分别了,各奔前程,大家珍重。
时间过得真快,四年时间在不知不觉中就慢慢的过去了,随着毕业时间的逐渐推进,毕业设计的进行也逐渐进入了尾声,在这里衷心的对在整个毕业十几过程中给我帮助的老师和同学,这次毕业设计从一开始的选题就是在指导老师的细心指导下选定的,而且在我实现系统的过程中对我悉心指导,指导老师在我完成毕业设计过程中对我的帮助很大,没有他们的认真负责,这次毕业设计的进行也不会这么的顺利,对我毕业设计的完成帮助很大,通过这次的毕业设计是我对大学四年学习的知识的一次运用,也是一次巩固,在毕业设计的完成过程中,我遇到了很多的困难,遇到困难后,我通过在网上查询翻阅书籍以及询问老师和同学,锻炼了自己的动手能力,让自己对知识的记忆更加的牢固。毕业设计的完成过程中,我也学习了很多以前没有学过的知识,对我以后的工作有很大的帮助,让我的专业知识更加的充实。
最后由心的对在四年当中帮助过我的同学们和对我悉心栽培的老师们说一声谢谢。论文即将完成,想到老师对我的认真指导,我激动地心情久久不能平静,在这里请接受我诚挚的谢意!
外文翻译
Introduction of struts

    1. Talking the talk

This chapter explores the Struts framework in depth and highlights the benefits Struts can bring to your development efforts. We believe that once you can “talk the talk” of web architecture and design, you will be better equipped to use Struts with your own applications. With a sound overview of the Struts architecture in place, we outline the Struts control flow and the way it handles the request-response event cycle. A good understanding of this process makes it much easier to create applications that make the best use of the framework. Choosing a web application framework should not be a casual decision. Many people will use this book, and especially this chapter, as part of evaluating Struts for their project. Accordingly, we conclude this chapter with a candid look at the strengths and weaknesses of the Struts framework and address concerns regarding overall performance. Struts is designed for professional developers. To make informed decisions, professionals need to be aware of both a tool’s capabilities and its limitations.

2. Why we need Struts

Today’s web applications are critical components of the corporate mission. As always, development teams need to build applications in record time, but they have to build them right and build them to last. Java web developers already have utilities for building presentation pages, such as Java Server Pages and Velocity templates. We also have mechanisms for handling databases—JDBC and Enterprise JavaBeans (EJB), for example. But what do we use to put these components together? We have the plumbing and the drywall … what else do we need?

2.1 Enter Struts

The centerpiece of Struts is an MVC-style Controller. The Struts Controller bridges the gap between Model and View. The framework also includes other missing pieces developers need to write scalable, leading-edge web applications. Struts is a collection of “invisible underpinnings” that help developers turn raw materials like databases and web pages into a coherent application.

2.2 Struts controller components

The Struts controller is a set of programmable components that allow developers to define exactly how their application interacts with the user. These components hide nasty, cumbersome implementation details behind logical names. Developers can program these details once, then go back to thinking in terms of what the program does rather than how it does it. Users interact with a web application through hyperlinks and HTML forms. The hyperlinks lead to pages that display data and other elements, such as text and images. The forms generally submit data to the application via some type of custom action. As shown in figure 2.2, Struts provides components that programmers can use to define the hyperlinks, forms, and custom actions that web applications use to interact with the user. We used these components to build a starter application in chapter 1. In chapter 3, we walk through using these components to build another simple application. Then, in chapter 4, we provide a detailed overview of configuring these components. Later chapters provide more detail about putting each component to use within your application. In part 4 we demonstrate using the components in the context of working applications. But, since this chapter is the architectural overview, let’s go ahead and introduce the major Struts components now.

2.3 Hyperlinks

To the application developer, a hyperlink is a path to some resource in the application. This may be a web page or a custom action. It may also include special parameters. In Struts, developers can define a hyperlink as an ActionForward. These objects have a logical name and a path property. This lets developers set the path and then refer to the ActionForward by name. ActionForwards are usually defined in an XML configuration file that Struts reads when the web application loads. Struts uses the XML definitions to create the Struts configuration, which includes a list of ActionForwards. The XML element that would create an ActionForward for a welcome hyperlink might look like this:

<forward

name="welcome"

path="/pages/index.jsp"/>

This element would create an ActionForm JavaBean with its name property set to welcome and its path property set to /pages/index.jsp. JSP pages and other components can then refer to the welcome forward. The Struts framework will look up the welcome ActionForward bean and retrieve the path to complete the hyperlink. This allows developers to change the destination of a link without changing all the components that refer to that link. In most web applications, details like this are hard coded into JSP and Java code, making changes difficult and prone to error. In a Struts application, these details can be changed throughout the application without touching a single page or Java class.

2.4 HTML forms

The web protocols, HTTP and HTML, provide a mechanism for submitting data from a form but leave receiving the data as an exercise for the developer. The Struts framework provides an ActionForm class, which is designed to handle input from an HTML form, validate the input, and redisplay the form to the user for correction (when needed), along with any corresponding prompts or messages. ActionForms are just JavaBeans with a couple of standard methods to manage the validation and revision cycle. Struts automatically matches the JavaBean properties with the attributes of the HTML controls. The developer defines the Action- Form class. Struts does the rest.

2.5 Custom actions

An HTML form uses an action parameter to tell the browser where to send the form’s data. The Struts framework supplies a corresponding Action class to receive such data. The framework automatically creates, populates, validates, and finally passes the appropriate ActionForm to the Action object. The Action can then get the data it needs directly from the ActionForm bean. Here’s an example:

public final class LogonAction extends Action {

public ActionForward perform(ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

MyForm myForm = (MyForm) form;

// ...

return mapping.findForward("continue");

}

}

An Action concludes by returning an ActionForward object to the controller. This allows the Action to choose a definition using logical names, like continue or cancel, rather than system paths. To ensure extensibility, the controller also passes the current request and response object. In practice, an Action can do anything a Java Servlet can do.

2.6 ActionServlet

The Struts ActionServlet works quietly behind the scenes, binding the other components together. Although it can be subclassed, most Struts 1.0 developers treat the ActionServlet as a blackbox: they configure it and leave it alone. For more about configuring Struts, see chapter 4.

In Struts 1.1, the ActionServlet is easier to extend. Chapter 9 covers the new extension points and configuration options for the Struts 1.1 ActionServlet.

2.7 Localization

Web applications also interact with users through prompts and messages. The Struts components have localization features built in so that applications can be written for an international audience. We refer to the localization featuresthroughout the book.

2.8 Developing a web application with Struts

To build a web application with Struts, developers will define the hyperlinks they need as ActionForwards, the HTML forms they need as ActionForms, and whatever custom server-side actions they need as Action classes.Developers who need to access EJB or JDBC databases can do so by way of the Action object. This way, the presentation page does not need to interact with the Model layer. The Struts Action object will collect whatever data a View may need and then forward it to the presentation page. Struts provides a JSP tag library for use with JSP pages that simplifies writing HTML forms and accessing other data that an Action may forward. Other presentation devices, such as Velocity templates, can also access the Struts framework to create dynamic web pages.

3. Why we need frameworks

In chapter 1, we introduced application frameworks and briefly discussed why frameworks are important. But to really understand a solution, you need to appreciate the problem. Developing for the web, while rewarding, brings its own set of challenges. Let’s take a quick look at what makes web development so challenging.

3.1 The Web—a never-ending kluge

Web developers are hampered by a double web whammy. First, we are expected to use web browsers for clients. Second, we must use the web protocol to communicate. Web browsers communicate via Hypertext Transmission Protocol (HTTP) and display pages created with Hypertext Markup Language (HTML). A web browser sends out the HTTP request and renders the HTML it receives in response. This is an excellent platform for serving prewritten pages that rarely change. But most of us are writing dynamic applications with pages that are customized for each user. While there are some handy “hooks” for dynamic features, web applications go against the HTTP/HTML grain. Sadly, the situation is not going to change any time soon. Web developers must see these shortcomings as challenges to overcome. Since there are so many obstacles to writing robust web applications, using a framework is vital, lest your application become an endless series of workarounds and kluges. The challenges we face when developing web applications are great. But so are the rewards. The duo of the HTTP protocol and the HTML client makes web applications accessible to people the world over. No other platform has ever been able to make that claim.

3.2 The servlet solution

As mentioned in chapter 1, the Java Servlet platform [Sun, JST] acts like a base framework to provide Java web applications with a number of important capabilities. The servlet class provides a base interface for handling HTTP requests and the ensuing response. It builds on HTTP to provide a “session” context to help track users in the application. It provides other contexts to help applications pass data to the browsers or to other servlets in the application. Java web applications also have uniform access to basic security features that would otherwise be managed differently by different HTTP servers. To put this all together, the servlet specification describes a container to manage the servlets. The container may also provide other services, such as a handler for JSP. A servlet container can include its own web server or simply act as an adjunct to an existing web server.

For database access, Java applications have another common framework at their disposal: JDBC. Developers can write to a standard SQL interface while an adapter takes care of the hoary details. This makes it easier to change database vendors without rewriting the source code.

For high-performance applications that access database systems on remote servers, web developers can use the Enterprise JavaBean platform. Most Java application frameworks, including Struts, can be used with EJB when they are needed. Overall, this makes web applications based on Java servlets very portable and relatively easy to write and maintain. Servlet and JSP have made a real difference in the way we write applications. Java web application frameworks like Struts build on the servlet platform and try to provide developers with a seamless, kluge-free environment.

3.3 Servlet frameworks

Most, if not all, Java web frameworks use the Sun Servlet platform as a foundation. These frameworks bundle one or more prewritten servlets that you can plug into your application. A framework will also include a hierarchy of classes that you can implement or extend within your own http://application.In general, the focus of a web application framework is to help get the data you need out of a browser and into a programming structure, where your application can use it—or out of a programming structure and into a browser, where your user can see it.Some frameworks, such as Turbine [ASF, Turbine], also provide helper classes for working with JDBC databases. Other frameworks, like Struts, are model neutral.

They don’t hinder database access but neither do they help. Even other frameworks, like dbForms [dbForms], specialize in database access and leave other tasks as an exercise for the developer (or to another framework, like Struts).

3.4 The whitebox-blackbox continuum

Frameworks are sometimes categorized into a continuum with poles labeled whitebox and blackbox [Fayad]. Whitebox frameworks rely heavily on object-oriented language features such as inheritance and dynamic binding. Blackbox frameworks tend to define interfaces for pluggable components and then provide base starter components based on those interfaces. The interface and base components will often provide hotspot methods that can be used as is or overridden to provide special behavior. Like many real-life frameworks, Struts uses a mix of whitebox and blackbox techniques. But overall, the framework would be placed toward the blackbox end of the continuum. Blackbox frameworks often rely strongly on design patterns. Struts is no exception. In fact, design patterns are often used to provide higher-level descriptions of frameworks [Johnson]. In keeping with this trend, let’s introduce the design patterns and show how they are used within the Struts framework.

4. The evolution of MVC

The MVC example in Design Patterns extols its use of the notify/subscribe protocol and the Observer pattern. The essentials of the example are that a system needs to display several different views of the same data, such as a bar chart, piechart, and spreadsheet. This is an excellent justification for compartmentalizing applications, and the example has been often repeated.

4.1 The rise of Model 2

JavaServer Pages are intended make dynamic web pages easier to write. JSPs were first introduced as an alternative to servlets, as well as to Microsoft’s Active Server Pages. Developers were offered the power of servlets as easy-to-create server pages. But with great power comes great responsibility. Many teams found that if they were not careful, a project could easily collapse under the weight of hopelessly intertwined pages. Advanced features required the use of complex scriptlets. Butscriptlets are difficult to reuse—unless you’re pasting the code from page to page.

Utility pages can be included, but they are difficult to keep organized and make for some very ugly “source” trees. Something was wrong with this picture. Many developers soon realized that JSPs and servlets could be used together to deploy web applications. The servlets could cope with the control flow; the JSPs could focus on the nasty task of writing HTML. In due course, using JSPs and servlets together became known as Model 2 (using JSPs alone was referred to as Model 1). Of course, there is nothing new under the Sun... and many have been quick to point out that JSP’s Model 2 resembles the classic Model-View-Controller http://architecture.In some circles, it is now commonplace to use the terms Model 2 and MVC interchangeably, although some dispute whether an application can be MVC and not support the classic Observer notification pattern. Model-View-Controller without the notification pattern is sometimes called MVC2 or Web MVC.

4.2 Application layers—decoupling the view

Many architects of distributed systems, including web applications, wince at the idea of the view making a state query. Most often, remote applications are designed around the Layers pattern [POSA]. Essentially, the Layers pattern says that classes may interact with classes in their own layer or classes in an adjacent layer. In a complex application, this keeps dependencies from growing exponentially as components are added. Layering is a core pattern in the design of remote applications.From an MVC context, introducing the Layers pattern puts the responsibility for both state changes and state queries onto the Controller along with any change notifications. The major responsibilities of each component are unchanged. The flow changes slightly in that any state query or change notification must pass through the Controller. Another difference is that when the View, or presentation layer, renders dynamic content, it uses data passed by the Controller rather than data returned directly by the Model. This change decouples the View from the Model, allowing the Controller to select both the data and View that displays the data.

5. Struts control flow

Since web applications are dynamic, it’s difficult to represent the “One True Control Flow.” Depending on the circumstances, a lot of different things can happen in different ways—especially in web applications. But there is still a general order to things that we can review here.

If you are new to Struts, or application frameworks, or even web applications, this process may seem hard to follow at first. The various problems it is trying to solve may not be evident. We’ll be covering those in detail throughout the book. Here, we try to take a look at the forest before introducing the trees. As you read through the book, we recommend that you revisit this section occasionally to see how the pieces fit into the big picture.

5.1 Is Struts performant

After a detailed description of the Struts process, you might wonder how long all this is going to take. In general, Struts should improve the performance of most properly designed web applications. In this section, we examine a few specific design points that contribute to the framework’s efficiency. Struts is not only thread-safe but thread-dependent. A lightweight Action object, rather than an individual servlet, handles the response to a request. Struts instantiates each Action class once and allows other requests to be threaded through the original object. This core strategy conserves resources and provides the best、possible throughput. A properly designed application will exploit this further by routing related operations through a single Action.

ActionForm beans minimize subclass code and shorten subclass hierarchies. A key point in the Struts framework is automatically populating any ActionForm bean from any request. Without this component, custom code may have to be written and instantiated to populate each class of bean. The careful use of reflection saves resources, which are always finite, allowing them to be put to better use.

The Struts tag libraries provide general-purpose functionality. The bean and logic taglibs bundled with Struts can meet most JSP tag needs. They reduce or even eliminate the need to write and instantiate additional tags. The JSP specification includes tag reuse within a JSP. Using the same general-purpose tag three times is more performant than using three different tags. The Struts components are reusable by the application. Utilities bundled with the framework have uses throughout most applications. The BeanUtil.populate method is a good example. This method is used to populate form beans from an HTTP request but can also be used to populate any bean from any type of map. Reusing components reduces overhead and conserves resources.

The Struts localization strategies reduce the need for redundant JSPs. By allowing localized messages to be retrieved at runtime, internationalized applications can provide a single page where one page for each language would otherwise be needed. Meanwhile, the same messaging system is also used to handle error messages, providing dual use of the same objects. Struts is designed with an open architecture. Struts components are designed so that they can be subclassed by an application to provide additional functionality. This allows developers to extend existing classes rather than add the overhead of creating and integrating new classes. Also, Struts shares its resources with the application. This allows developers to leverage existing components, so they do not have to write and instantiate their own. Struts is lightweight. Similar frameworks may provide hundreds of classes or tags and dozens of packages. The entire Struts framework is made up of five tag libraries and five core packages.

Struts is standards compliant. Many containers are designed to perform best when using standard components—JSP and JavaBeans, for example. Struts is open source and well documented. This means developers can easily examine the code to identify and resolve any potential bottlenecks.

Struts is model neutral. Since Struts does not make any assumptions about the backend model, an application can implement the Model layer in the most efficient way possible. Struts Actions can call a set of helper classes to access needed data. Once the data is retrieved, Struts’ reliance on JavaBeans makes it easy to retain value objects and reduce the number of calls to the Model layer.

Struts简介

1 探讨Struts

本章深入探讨Struts 框架,以及它能给你的应用开发所带来的诸多好处。我们相信,一旦你也能“随便谈谈”web 架构和设计,你就可以很好的在你的应用中使用Struts。为了能对Struts 架构有个充分的全面印象,我们将总体介绍Struts 的控制流和它处理请求响应事件循环的方式。只有彻底理解这个处理原理才能最好的在应用中使用这个框架。选择一个web 应用框架不应该是个漫不经心的决定。很多人都可以使用这本书,特别是用这章的内容,来评价Struts 是否适合它们的项目。因此,我们在这章的最后部分将有一个关于Struts 优缺点的客观评价,并阐明其总体性能。Struts 设计来针对专业开发人员。为做出正确的决策,专业人员应该知晓工具的能力和限制。

2 为什么我们需要Struts

今天的web 应用基本上都是代表共同理念的关键组件。通常,开发团队需要在有限的时间里创建应用,然后它们不得不正确的构建,并能持续构建它。Java web 开发人员已经有一些工具可用来建立表现层,比如JavaServer Pages 和Velocity模板。也有一些机制来处理数据库—如JDBC 和Enterprise JavaBean (EJB)。但我们用什么来将它们集合在一起?我们已经有了型材和砖墙…还缺什么呢?

2.1进入Struts

Struts 的核心是一个MVC 风格的控制器。Struts 控制器搭起了Model 和View 之间的桥梁。框架也包括开发人员想用来开发可伸缩的、先进的应用系统的其他组件。Struts 是一个“隐藏支柱”的集合,帮助开发人员将分散的材料,如数据库和页面,结合成一个整体的应用系统。

2.2Struts控制器组件

Struts 控制器组件是一个可编程的组件集,允许开发人员定义它们的应用如何准确地和用户进行交互。这些组件在逻辑名称后面隐藏了令人讨厌的、繁琐的实现细节。开发人员可以一次性编写这些实现细节,然后转头考虑它们的应用应该做什么,而不是考虑应用应该如何做。用户通过超链接和HTML form 与Web 应用程序进行交互。超链接引导页面显示数据和其他内容,如文本和图像。表单通常通过一些定制动作向应用提交数据。Struts 提供了开发人员可用来定义超链接,表单,和定制动作这些交互的相关组件。我们已经使用这些组件在第1 章创建了一个入门程序。第3 章,我们还要用它们来创建另一个程序。然后,在第4 章,我们将讨论这些组件的详细配置。随后的章节,将详细讨论如何将每个组件以及如何用在你的程序之中。在第4 章,我们将展示如何在运行的程序上下文中使用这些组件。但是,因为这一章是架构性的总体介绍,所以我们继续介绍Struts的主要部件。

2.3 超链接

对应用开发人员来说,超链接是指向应用中某些资源的路径。这些资源可能是web 页面,或者是定制动作。超链接中也可以包含特殊的参数。在Struts 中,开发人员可以将超链接定义为一个ActionForward。这些对象都有个逻辑名称和一个path 属性。这使得开发人员可以设置path,然后通过名称来引用ActionForward。ActionForward 通常在一个XML 文件中定义,这个配置文件在Struts 启动时载入。Struts 使用XML 定义来创建Struts 配置,包括一个ActionForward的列表。可用来创建到欢迎页面链接的ActionForward 对象XML 元素看起来可能像:

<forward

name="welcome"

path="/pages/index.jsp"/>

这个元素事实上是创建了一个ActionForward JavaBean ,其name 属性设置为welcome,path 属性设置为/pages/index.jsp。JSP 页面和其它组件就可以引用这里定义的welcome 转发。Struts 框架将查找welcomeActionForward bean 并获取其path 属性以完成这个超链接。这样开发人员可以改变链接的目标而不用

变所有引用该链接的相关件。在很多Web 应用中,象这样的细节被硬编码到JSP 或Java code 中,使维护变得困难并且容易发生错误。在Struts 应用中,这些细节可以通过应用配置来改变,而不用触及到具体的页面和Java 类。

2.4 HTML表单

Web 协议,即HTTP 和HTML,提供了一个从表单中提交数据的机制,但却把数据的接收作为一个难题留给了开发人员。为此,Struts 框架提供了ActionForm 类。ActionForm设计来就是处理来自HTML 表单的输入:校验输入,重新显示表单以供用户进行修订(如果需要),以及伴随着相应的提示和错误信息。ActionForm 其实是具有一些用来来管理校验和修订循环的标准方法的JavaBean。Struts 自动匹配JavaBean 属性和HTML 表单控件的属性。开发者只需定义ActionForm 类,余下的就交给Struts 。

2.5 Custom actions

定制动作 HTML 表单使用action 参数来告诉浏览器将数据送到何处。Struts 框架提供相应的Action 来接收数据。框架会自动创建、组装、校验和最后处理Action 对象所对应的ActionForm。这样,Action 就可以直接从ActionForm bean 取得它需要的数据。比如下例:

public final class LogonAction extends Action {

public ActionForward perform(ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws IOException, ServletException {

MyForm myForm = (MyForm) form;

// ...

return mapping.findForward("continue");

}

}

Action 根据返回到控制器的ActionForward 对象作出控制流的决定。这允许Action 选择一个逻辑名称,比如continue 或者cancel,而不是具体的系统路径。

为保证可扩展性,控制器也传递当前的请求和响应对象。实际上,Action 可以做所有JavaServlet 可以做的事情。ActionMapping在一个web 应用中,每个资源都必须通过URI 来进行引用。资源束括HTML 页面,JSP页面,和定制动作。为了给定制动作一个URI,或者说路径,Struts 框架提供了一个ActionMapping 对象。象ActionForward 和ActionForm 一样, ActionMapping 通常也在XML 配置文件中定义:

<action-mappings>

<action path="/logonSubmit"

type="app.LogonAction"

name="logonForm"

scope="request"

validate="true"

input="/pages/logon.jsp" />

</action-mappings>

这也允许将同一个Action 对象定义为不同的ActionMapping。例如,其中一个映射要求校验而另一个映射不要求校验。

2.6 ActionServlet

Struts ActionServlet 完全在幕后工作,它将其他组件绑定在一起。虽然它也可以子类化,但大多数Struts 1.0 的开发人员将ActionServlet 处理为一个黑盒:他们只是配置它,然后让它自己工作。在Struts 1.1 中,ActionServlet 是比较易于扩展的。第9 章将讨论Struts 1.1 ActionServlet新的扩展点和配置选项。

2.7 本地化

Web 应用也通过各种提示和信息与用户进行交互。Struts 组件均有内建的本地化特征,以便Struts 应用可以为国际化用户使用。我们在此书中贯穿使用本地化特征。

2.8 用Struts开发Web应用

要使用Struts 开发web 应用,开发人员将需要的超链接定义ActionForward,HTML 表单定义为ActionForm,定制的服务器端动作定义为Action 类。需要访问JDBC 和EJB 的开发人员也可通过Action 对象进行他们的工作。这样,表现层不需要和Model 层打交道。。Struts Action 对象将收集View 需要的数据,然后将它们转发到表现页面。Struts 提供JSP 标记库,它们将和JSP 页面一起使用,简化HTML 表单和访问Action 要转发的其它数据。其它表现机制,比如Velocity templates, 也可用来访问Struts 框架,以创建动态的web 页。

3 为什么需要框架

第1 章,我们介绍了应用框架,简短讨论了为什么框架很重要。但为了真正理解一个解决方案,我们需要了解问题所在。为web 开发应用虽然是值得的,但也要迎接各种挑战。让我们快速看看是什么使web 开发富有挑战。

3.1Web—永无休止的修补

Web 开发者受到两种web 缺陷的影响。首先,我们希望使用浏览器作为客户端。其次,我们必须使用web 协议进行通讯。Web 浏览器通过HTTP 协议通信,并用HTML 显示页面。Web 浏览器发送HTTP 请求,并渲染和显示它收到的响应。在处理很少改变的预先编好的页面时,这是个很好的平台。但我们大多都是编写动态程序,页面针对不同的用户是不同的。虽然有一些现成的动态特征的手段,web 仍然受到HTTP/HTML 的制约。很不幸,这种状况现在并没有些许改变。Web 开发人员在想战胜挑战时必须首先看到这些缺陷。因为这对编写强壮的Web 应用有太多障碍,使用框架便显得至关重要,免得你的应用陷入无休止的工作和改进之中。在开发Web 应用时我们面临的挑战是很巨大的。但同时也是值得的。HTTP 协议和HTML客户端使所有的人都可以访问你的应用。没有其他哪个平台能声称这样。

3.2Servlet 解决方案

如第一章所述,Java Servlet 平台[Sun, JST] 扮演了一个基本框架,为Java web 应用提供了大量的能力。Servlet 提供了一个处理HTTP 请求和确保响应的基本接口。它在HTTP 之上构建了一个“会话” 上下文,帮助跟踪应用程序的用户。当然它也提供其他的上下文,帮助应用传输数据到浏览器或者应用中的其他servlet。Java web 应用也具有对基本安全特性的统一访问,而这些安全特性在不同的服务器上的管理是不一样的。为了将这些内容集成在一起,Servlet 规范引入了一个容器来管理它们。容器也可以提供其他服务,比如作为一个JSP 的处理器。Servlet 容器可以包含它自己的web server,也可以简单的作为一个现有服务器的附属组件。对数据库访问,Java 应用在其建议中有另外一个通用的框架:JDBC。开发者可以编写标准的SQL 接口,而将烦人的细节留给适配器来处理。这使得可以很容易的改变数据库厂商,而不用重写源代码。为了取得远程服务器的高性能数据库访问,web 开发人员可以使用EJB 平台。大多数Java应用框架,包括Struts, 都可以和EJB 一起使用。

总之,这使得基于Servlet 的web 应用非常轻便,并相对易于编写和维护。Servlet 和JSP在编写应用中扮演了完全不同的角色。象Strtus 这样的Java web 应用框架就构架于Servlet 之上,给开发者提供一个无缝的集成环境。

3.3Servlet 框架

大多数,不是全部,Java web 框架使用Sun Servlet 平台为基础。这些框架都绑定一些预制的servlet,你可以插入到你的应用中去。框架本身也包括一个类层次结构,这些类(或接口)你可以在你的应用中实现或者扩展。通常, 应用框架的目标是帮助你将你需要的数据从浏览器发出,进入到编程结构之中,这样你的应用就可以使用它—或者从编程结构中发出,进入到浏览器之中,这样你就可以看到。一些框架,如Turbine [ASF, Turbine],也提供helper 类来使用JDBC 数据库。其他框架,如Struts,则是模型中立的。它们既不阻碍数据库访问,也没有提供帮助。而某些框架, 如dbForms [dbForms],则专注于数据库访问,而将其它任务留给开发人员或者其他框架。

3.4黑盒-白盒统一体

框架有时分为两极标有白盒和黑盒的统一体[Fayad]。白盒框架严重依赖于面向对象的语言的特征,如继承和动态绑定。黑盒框架则注重定义可插入组件的接口,然后基于这些接口提供基本的起始组件。接口和基本组件通常提供热点(hotspot)方法,这个方法可以直接使用或者重写后提供特别的行为。像许多正在使用的框架,Struts 使用混合的黑盒和白盒技术。但总体上,框架将偏向统一体的黑盒一端。黑盒框架通常依赖于设计模式。事实上,设计模式通常被用来作为框架的总体描述[Johnson]。为保持这个趋势,我们先介绍一下设计模式,以及它们是如何用在Struts框架之中。

4 MVC的演化

Smalltalk MVC 方案使用观察者通知模式。在这种模式下,每个视图注册为一个模型数据的观察者。然后模型可以通过发送消息给所有这册观察者,通知它们相关的改变。其为Smalltalk MVC 框架已经通用化了,他也可以将它应用到其他平台上面。

4.1Model 2的出现

JSP 的意图是使创建动态页面更容易。JSP 首先是作为servlet 的替代引入的,还有就是MS的ASP。Servlet 的强大功能当作易于创建服务器页面的工具提供给开发者。但强大的功能伴随着巨大的责任。很多团队发现,如果他们一不小心,他们的项目就会因为纠缠如麻的页面变的容易崩溃。进一步的特性需要使用复杂的脚本程序。但脚本程序是非常难于重用的—除非你在页面间把代码“拷贝粘贴”。工具页面也可以包括进来,但它们很难被组织在一起,并且造成非常丑陋的“资源”树。有些东西会出错。很多开发人员很快意识到,JSP 和servlet 可以一起使用来部署web 应用。Servlet 可以应付控制流,而JSP 则可专注于讨厌的编写HTML 的任务。在这种情况下,结合使用JSP和servlet 开始被称为Model 2 (单独使用JSP 称为Model 1)。当然,从Sun 那里仍然没什么新东西... 而且很多人很快指出JSP Model 2 类似于经典的Model-View-Controller 架构。在很多场合,现在交互使用Model 2 和MVC 这两个词已经很平常了,虽然还有一些争论,即一个应用是否是MVC,以及是否支持经典的观察者通知模式。没有观察者通知的Model-View-Controller 有时被称为MVC2 或Web MVC。

4.2应用层—视图之间的去耦合

许多分布式系统架构,包括web 应用,在视图进行状态查询的概念时退缩了。绝大多数情况下,远程应用是按层模式[POSA]设计的。基本上,层模式下,层内的对象可以和同一层或者相邻层的对象进行通信。在一个复杂应用中,这可以在添加组件时,防止依赖关系呈指数增长。在设计远程应用时,分层是一个核心模式。从MVC 上下文中,引入层模式将状态改变和状态查询的职责加于控制器之上,并伴随着改变通知。每个组件的主要职责并没有改变。流程有轻微改变,即查询状态和改变通知都必须通过控制器。另一个改变是,当视图,或者表现层需要渲染动态页面时,它使用从控制器传递的数据而不是直接来自于模型层。这种改变去除了View 和Model 的耦合,允许控制器选择数据和显示这些数据的视图。

5 Struts 控制流

因为web 应用是动态的,所以很难表现“一个真正固定的控制流”。取决于环境,不同的方式下有很多不同的事情发生—特别是在web 应用中。但是事情仍然有一个通用的秩序。如果你是个Struts,应用框架,甚至web 应用的新手,这些流程刚开始可能难以跟得上(理解)。亟待解决的各种问题不一定那么明显。我们将在本书中慢慢详细涉及。首先,在介绍树木之前我们先认识这片森林。你读完此书后,我们建议你再次回来,看看每一部分是如何切合进这个总图的。

5.1Struts 是富有效率的吗

详细描述完Struts 处理流程后,你可能会想知道这些的花多长时间。通常,Struts 应该能提升大部分正确设计的Web 应用的性能。在本节中,我们检查一些关系到框架效率的特殊设计点。

Struts不仅是线程安全(thread-safe)而且是线程依赖(thread-dependent)的Struts 使用轻量的Action 对象,而不是各个单独的servlet,来对请求处理响应。Struts 实例化每个Action 类一次,并允许其他请求通过原有的对象线程化。这种核心策略节省了资源,并提供最大的吞吐性。一个正确设计的应用将通过使用一个单独的Action 来路由各种相关操作来发挥这种特征。ActionForm bean最小化子类代码并缩短子类层次。Struts 框架的一个关键点是可以从请求中自动组装ActionForm bean 。没有这个组件, 用户不得不自行编写代码并实例化来组装每个bean 类。小心使用反射机制会节省不少资源,资源是有限的,并允许它们更好的使用。

Struts 标签库提供通用功能,Struts 一起提供的bean 和logic 标记库符合大部分JSP 标记的需要。它们减少甚至消除了编写额外标签的需要。JSP 规范就包含了JSP 中的标签重用。使用相同的通用标签3 次比使用3 次不同的标签来的有效率。

Struts 组件对应用来说都是可重用的框架绑定的工具可以在大部分应用中使用。BeanUtil.populate 方法就是个例子。这个方法用来从HTTP 请求组装一个ActionForm Bean,但也可以用来从其它类型的映射中组装一个FormBean。重用组件可以减少开销和节省资源。

Struts本地化策略减少了大量冗余JSP通过允许本地化页面在运行时才获取,国际化应用可以为每种可能需要的语言只提供一个单独的页面。同时,相同的消息系统也可以用于处理错误信息。同一对象提供了双重用途。

Struts设计为一个开放架构Struts 组件设计来是可以被应用子类化的,以便可以提供其它的服务功能。这使得开发人员可以扩展存在的类而不是重新编写新类。而且,Struts 也和应用共享资源。这时开发人员可以使用存在的组件,而不用编写和实例化它们自己的类。

Struts is a lightweight framework similar to perhaps providing hundreds of classes and dozens of packages. The entire Struts framework consists of 5 tag libraries and 5 core packages.

Struts is standards compliant Struts works very well with many containers running standard components.

Struts is open source and well documented, which means that developers can examine the source code to identify potential bottlenecks. And Struts is model neutral. Because Struts makes no assumptions about the back-end model, an application can implement the model layer in the most efficient way it can. Struts Actions can call a series of helper classes to access the required data. Once the data is retrieved, the reliance on JavaBean makes it easier for Struts to keep value objects, thus reducing a lot of model layer calls.

Guess you like

Origin blog.csdn.net/m0_66999594/article/details/128665915