I am doing my first steps with Struts 2 and the struts2-convention-plugin, currently working on a CRUD action class (SongCrudAction
) with some typical create()
, edit()
, view()
and delete()
action methods. All those methods are annotated with @Action
.
Generally, I'd like to inherit the useful default behavior from ActionSupport
, but that also includes inheriting the execute()
method.
Using the configuration browser, I can see that there is an action named song-crud
pointing to it. That song-crud
action is obsolete and I'd like to get rid of it, as I've got my own action methods for all desired operations. I guess, thanks to Struts2 conventions, that song-crud
action is assumed although I haven't declared it anywhere.
In this particular case, one possible solution would be to give some reasonable meaning to the execute()
method, e.g. I could use it for the view()
operation. A drawback would be that the action class should then be renamed (or annotated?) according to the execute()
method's behavior (e.g. ViewSongAction
instead of SongCrudAction
). Otherwise, the view action's URL would be inappropriate (i.e. /view-song?id=5
would fit better than /song-crud?id=5
).
On the other hand, renaming the class would be ugly, too, because it's just a CRUD and not a view action class.
Anyway, the general problem remains: whenever I inherit from ActionSupport
, it presents me with an execute()
method which may or may not be useful for what I'm doing.
So, it seems reasonable to somehow tell Struts 2 to exceptionally forget about the execute()
method in my CRUD action class. Is that right, and how can I achieve that? Is there a better solution?