What Is New in Apache Struts 2.1
This release focuses on major framework upgrades and plugin consolidation. Here's a quick summary of the key changes.
| Category | Key Changes |
|---|---|
| New Features | Convention Plugin integration, Portlet 2.0 support, New REST plugin |
| Improvements | Reduced configuration, Enhanced JUnit support, Better i18n |
| Deprecated | Codebehind Plugin, ActionMapperUtils class |
| Bug Fixes | Various issues across core, tags, and plugins |
How did plugin architecture change in 2.1?
The biggest shift was making the Convention Plugin a core part of the framework. This move away from XML configuration means you can use annotations and conventions for zero-config actions.
In practice, this simplifies development by eliminating huge amounts of struts.xml boilerplate. The old Codebehind plugin was officially deprecated in favor of this new approach.
What portlet support was added?
Full Portlet 2.0 (JSR-286) support was introduced. This lets you build Struts applications that run within portlet containers like Liferay or IBM WebSphere Portal.
The update includes new portlet-specific interceptors and components. This matters because it aligns Struts with modern enterprise portal requirements without needing custom hacks.
Were there any testing improvements?
Yes, JUnit support got a significant upgrade. The StrutsTestCase and StrutsSpringTestCase classes were enhanced to make unit and integration testing more straightforward.
You can now test your actions more effectively with better mock objects and setup utilities. This was a common pain point in earlier versions that received focused attention.
What happened to the REST plugin?
The REST plugin was completely rewritten from the ground up. The new version provides a cleaner, more flexible approach to building RESTful web services with Struts.
It offers better content negotiation and HTTP method handling. If you're building APIs, this rewrite makes Struts a much more viable option compared to dedicated REST frameworks.
FAQ
Is the Convention Plugin now required in Struts 2.1?
No, it's not required but it's now
bundled as the preferred approach. You can still use traditional XML configuration if needed, but the
convention-based approach reduces configuration significantly.
Does the Portlet 2.0 support break compatibility with Portlet 1.0?
Yes, the Portlet 2.0
support is not backward compatible with Portlet 1.0. You'll need to update your portlet applications to meet the
JSR-286 specification.
What should I use instead of the deprecated Codebehind plugin?
Use the Convention Plugin
that's now included in the core. It provides the same zero-configuration functionality but with better
implementation and ongoing support.
Were there any changes to internationalization support?
Yes, i18n support was improved with
better resource loading and message resolution. The framework now handles localized messages more efficiently
across different contexts.
How does the REST plugin rewrite affect existing applications?
Existing applications using
the old REST plugin will need to be updated. The new implementation has different configuration and API
patterns, so some migration work will be required.