actionstruts1struts-action

How to create a BaseAction for Struts 1?


I have this problem:

I need to create a BaseAction for a java web application (with Struts 1). All the actions will extend this BaseAction and all the actions have more methods (create, update, delete, list, etc). There's no "execute" method.

I need this in order to get the ApplicationContext for spring but also for authentication or other things that all actions should do.

When there's only "execute" method the things are easy...just create the BaseAction with "execute" method and an abstract "performTask" method. The "forward" will be the result of the "performTask" method that all other actions will implement.

So I can't do the same design for actions that have more than one method and every method has its own forward.

Thanx, Adri108


Solution

  • In Struts 1, struts-config.xml is a driving file. This file redirects various actions to respective ActionForward method.