Single Instance and multiple instances
Stateful storage is a data storage function, such as shopping cart. If you want to buy something and put it in, you can purchase or delete it again.
Stateless is an operation and data cannot be saved.
A stateful object is an object with a member attribute. It can store data and is non-thread-safe.
Stateless objects are objects without Member attributes. data cannot be saved, which is thread-safe.
Struts2 actions are stateful and non-thread-safe, so they are multi-instance.
The struts1 action is stateless and thread-safe, so it can be a single instance.
Non-Intrusive Design
Struts2 is not closely coupled with Servlet APIs as struts1 does. Applications of struts2 do not depend on servlet APIs and Struts APIs. This design of struts2 is a non-intrusive design, while struts1 is an intrusive design.
Ognl Expression Language
Ognl provides a simple way to access data in various scopes in struts2. You can easily obtain data in request, attribute, application, session, and parameters.
Interceptor Used
The interceptor of struts2 is an action-level AOP. Many features of struts2 are implemented through the interceptor, such as exception handling, file upload, and verification. The Interceptor is configurable and reusable. Some common functions such as logon verification and permission verification can be placed in the Interceptor to complete some common functions in Java Web projects. In my web project, the struts2 interceptor is used to complete the permission verification function in the system.
Global result and declarative exception
Add a global result for the application and handle the exception in the configuration file. This function is very useful when a specified exception occurs during the processing.
Easy type conversion
Struts2 provides a type converter that converts special request parameters to the desired type. If the same function is implemented in struts1, you must register the type converter with the underlying implementation of beanutil in struts1.
Others
Struts2 supports multiple presentation layer technologies, such as JSP, freemarker, and velocity.
The input validation of struts2 can be used to verify the specified method, solving the long-lasting pain of struts1.
Struts2 provides international resource file management for the global scope, package scope, and Action Scope.