Struts2: Why to extend ActionSupport class?

user663724 picture user663724 · Sep 12, 2011 · Viewed 18.4k times · Source

I am a beginner to Struts2. Please tell me why to extend ActionSupport class? (When one doesn't have the requirement of validation or internationalization)

Are there any other benefits provided by extending ActionSupport class?

Answer

Dave Newton picture Dave Newton · Sep 12, 2011

Convenience and access to basic, common functionality.

It has default implementations of common methods (e.g., execute(), input()), gives access to Action.SUCCESS and other result names, etc.

Note that the I18N functionality goes a bit beyond simple translation, but includes some formatting, allows non-programmers to provide labels/texts, and so on.

There's rarely (ever?) a good reason not to extend it. Even REST plugin actions, e.g., those that handle JSON endpoints, often use validation and I18N support.