14

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?

Steven Benitez
  • 10,936
  • 3
  • 39
  • 50

2 Answers2

15

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.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
6

IF you don't want to use out of the box features provided by the struts2 you can always avoid using ActionSupport class

This is basically a helper class which provides many out of the box features for you, but at same time Struts2 framework do not ask to use this class, all it want is an entry method for your action class with return type as String and which can throw a general Exception

beside validation or Internationalization this class also provides many other features like Action level Errors etc.

Follow the documentation for detail

ActionSupport

Umesh Awasthi
  • 23,407
  • 37
  • 132
  • 204