Struts advantages and disadvantages

Source: Internet
Author: User
Like many Apache projects such as Tomcat and turbine, Struts is an open-source software, which has a major advantage. This allows developers to gain a deeper understanding of their internal implementation mechanisms. The struts open source framework is created to make it easier for developers to build Web applications based on Java Servlet and JavaServer Pages (JSP) technology. The Struts framework provides a unified standard framework for openers. By using struts as the basis, developers can focus more on the business logic of applications. The Struts framework is a Model-View-controller (MVC) implementation that uses Java Servlet and JavaServer Pages technology.
Specifically, Struts has the following advantages:

1. Implement the MVC mode with a clear structure, allowing developers to focus only on the implementation of business logic.

2. There are a variety of tags that can be used. The struts tag Library (taglib) can be used flexibly to greatly improve development efficiency. In addition to common JSP tags, JSP developers in China rarely develop their own tags. Struts may be a good starting point.

3. page navigation: page navigation will be a future direction. In fact, this will make the system context clearer. With a configuration file, you can grasp the relationship between all parts of the system, which is of great benefit for later maintenance. This advantage is especially evident when another group of developers take over the project.

4. Provides the exception handling mechanism.

5. Database Connection Pool Management

6. Support for i18n

Disadvantages:
1. When you go to the presentation layer, You need to configure forward. Every time you go to the presentation layer, I believe most of them are directly forwarded to JSP. To switch, you need to configure forward, if there are ten JSP display layers, you need to configure struts for ten times, and sometimes directories and files need to be modified again. Note that after each configuration modification, it is required to re-deploy the entire project, and the servers such as the replicate must also be restarted. If the business changes complicated and frequent systems, such operations are simple and unimaginable. This is the case now. We can imagine how much trouble I have with hundreds of people using our system online at the same time.
 
2. Struts action must be thread-safe. It only allows one instance to process all requests. Therefore, all resources used by action must be synchronized in a unified manner, which causes thread security issues.

Iii. Test is inconvenient. Every action of Struts is coupled with the web layer, so that its test depends on the Web container, and unit test is difficult to implement. However, there is a JUnit extension tool struts testcase which can implement unit testing.

Iv. type conversion. Struts formbean regards all data as the string type. It can use the tool commons-beanutils for type conversion. However, the conversion is at the class level, and the conversion type cannot be configured. It is also very difficult to return error messages during type conversion to users.

5. The servlet dependency is too strong. Struts must depend on servletrequest and servletresponse when processing the action, and it cannot get rid of the servlet container.

6. In terms of front-end Expression Language, Struts integrates jstl, so it mainly uses the jstl Expression Language to obtain data. However, the expression language of jstl is very weak in collection and index attributes.

7. Difficult to control the execution of an action. It is very difficult to create an action in struts if you want to control its execution sequence. You even need to write the servlet again to meet your functional requirements.

8. Pre-and Post-action processing. Struts uses class-based hierarchies to process actions. It is difficult to perform operations before and after action processing.

9. Insufficient event support. in struts, a form corresponds to an action class (or dispatchaction). In other words, in struts, a form corresponds to only one event, struts is called Application Event. Application event is a coarse-grained event compared with component event.

An important form object of struts, actionform, is an object that represents an application. This object contains at least several fields, which are input fields in the JSP page form, because a form corresponds to an event, when we need to refine the event granularity to the fields in the form, that is, when a field corresponds to an event, it is impossible to simply use struts, of course, it can be achieved by combining JavaScript.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.