Home  >  Article  >  Java  >  What does java struct mean?

What does java struct mean?

(*-*)浩
(*-*)浩Original
2019-05-28 12:36:043799browse

Struts, like Tomcat, Turbine and many other Apache projects, is open source software, which is one of its great advantages. Allow developers to have a deeper understanding of its internal implementation mechanism. The Struts open source framework was created to make it easier for developers to build Web applications based on Java Servlet and JavaServer Pages (JSP) technologies. The Struts framework provides developers with a unified standard framework. By using Struts as the basis, developers can focus more on the business logic of the application.

What does java struct mean?

The Struts framework itself is a Model-View-Controller (MVC) implementation using JavaServlet and JavaServerPages technology.

Specifically,

The advantages of Struts are:

1. Implement the MVC pattern and have a clear structure, allowing developers to only focus on the implementation of business logic.

2. There are a wealth of tags that can be used. The Struts tag library (Taglib) can greatly improve development efficiency if it can be used flexibly. In addition, as far as domestic JSP developers are concerned, in addition to using the common tags that come with JSP, they rarely develop their own tags. Perhaps Struts is a good starting point.

3. Page navigation. Page navigation will be a development direction in the future. In fact, doing so will make the context of the system clearer. Through a configuration file, you can grasp the connection between various parts of the entire system, which is of great benefit for later maintenance. This advantage becomes even more obvious when another group of developers takes over the project.

4. Provide Exception handling mechanism.

5. Database connection pool management

6. Support I18N

Disadvantages:

1. When going to the display layer, you need to configure forward. Every time you go to the display layer, I believe most of them go directly to jsp. When it comes to redirection, you need to configure forward. If there are ten display layers. jsp needs to configure struts ten times, and this does not include sometimes directory and file changes, which require re-modification of forward. Note that every time the configuration is modified, the entire project is required to be redeployed, and for servers like tomcate, the server must be restarted. If the business changes to a complex and frequent system, such an operation is unimaginable. This is it now. Dozens or hundreds of people are using our system online at the same time. You can imagine how troubled I am.

2. Struts Action must be thread-safe, which only allows one instance to handle all requests. Therefore, all resources used by actions must be uniformly synchronized, which causes thread safety issues.

3. Testing is inconvenient. Each Action of Struts is coupled with the Web layer, so its testing depends on the Web container, and unit testing is also difficult to implement. However, there is a Junit extension tool Struts TestCase that can implement its unit testing.

4. Type conversion. Struts' FormBean treats all data as String type, and it can use the tool Commons-Beanutils for type conversion. But its conversion is all at the Class level, and the conversion type is not configurable. It is also very difficult to return error messages during type conversion to the user.

5. Too much dependence on Servlet. Struts must rely on ServletRequest and ServletResponse when processing Action, so it cannot get rid of the Servlet container.

6. In terms of front-end expression language. Struts integrates JSTL, so it mainly uses JSTL expression language to obtain data. However, JSTL's expression language is very weak in handling Collection and index properties.

7. It is difficult to control the execution of Action. When Struts creates an Action, it will be very difficult to control its execution order. You may even have to re-write the Servlet to realize your functional requirements.

8. Processing before and after action execution. When Struts processes action, it is based on class hierarchies. It is difficult to operate before and after action processing.

9. Insufficient support for events. In Struts, a form actually corresponds to an Action class (or DispatchAction). In other words: In Struts, a form actually corresponds to only one event. Struts This event method is called application event. Compared with component event, application event is a coarse-grained event.

Struts important form object ActionForm is an object that represents an application. This object contains at least several fields. These fields are input fields in the Jsp page form, because a form corresponds to an event. , Therefore, when we need to refine the event granularity to these fields in the form, that is, when one field corresponds to an event, it is impossible to simply use Struts. Of course, it can also be achieved by combining JavaScript.

The above is the detailed content of What does java struct mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn