What Is New in Apache Struts 2.2
This release brings a mix of new capabilities, refinements, and important fixes. Here's a high-level overview of the key changes.
| Category | Key Updates |
|---|---|
| New Features | Convention Plugin enhancements, REST Plugin update, new themes |
| Improvements | JSON support, JUnit plugin, OGNL and FreeMarker integration |
| Bug Fixes | Multiple issues resolved across core and plugins |
| Deprecations | Deprecated the Codebehind plugin and certain attributes |
What are the major new features?
The Convention Plugin got a significant boost, making annotation-based configuration even more powerful. It now supports configuring results and interceptors through annotations, which cuts down on XML configuration.
The REST Plugin was updated to its latest version, improving support for building RESTful web services. We also saw the introduction of new themes, giving developers more options for UI component rendering out of the box.
How was JSON handling improved?
JSON support received important upgrades for better integration. The JSON result type was enhanced to handle serialization more effectively.
In practice, this means your actions can return JSON data more reliably. The plugin handles collections and complex objects better, making it smoother to build AJAX-driven features.
What testing improvements were made?
The JUnit plugin was upgraded, providing better tools for testing Struts 2 actions. This makes writing unit tests for your action classes more straightforward.
You can now mock Struts infrastructure more effectively, leading to tests that are faster and less dependent on the full framework stack. This is a big win for test-driven development.
Were there any internal engine updates?
Yes, the integration with OGNL and FreeMarker was refined. These are core technologies for expression evaluation and template rendering in Struts.
The updates improve performance and reliability when evaluating expressions in your JSP tags or FreeMarker templates. You might not see these changes directly, but they make the framework more robust.
What has been deprecated?
The Codebehind plugin, which was a precursor to the Convention plugin, has been officially deprecated. If you're still using it, now's the time to migrate to the Convention approach.
Some specific attributes within tags and configuration elements were also marked for deprecation. The framework will log warnings to guide you toward the newer alternatives.
FAQ
Should I upgrade to Struts 2.2 for the JSON improvements alone?
If your application heavily uses AJAX and returns JSON from actions, the enhanced serialization makes the upgrade worthwhile. It handles complex objects more predictably.
Is the Convention Plugin now the recommended way to configure actions?
Absolutely. With the new annotations for results and interceptors, it significantly reduces XML configuration. The deprecation of Codebehind confirms this is the future.
What's the impact of the OGNL and FreeMarker changes?
For most developers, it's under-the-hood. You get better performance and fewer edge-case bugs when evaluating expressions in your views. No code changes should be needed.
I use the REST plugin. What does this update mean for me?
The plugin update includes bug fixes and compatibility improvements. It's a drop-in replacement that makes your RESTful endpoints more stable.
Are there any breaking changes I should watch out for?
The deprecations are the main concern. While they won't break your app immediately, start planning to replace deprecated code like the Codebehind plugin to avoid future issues.