How can I pass an attribute into my struts2 java action that tells me whether the action was called from one URL path / action mapping vs another?
I figured I could put something in the struts.xml for two action mappings but use the same java action and just pass in a flag into the action.
You’ll want to use the
<param/>tag. I do this frequently for actions that handle both adding and editing an entity, as the fields, validations, and whatnot are virtually identical. Here’s an example of that.struts.xml
The Action
In order for this to work, you need the static parameters interceptor in your stack (it’s included by default).