How to map two action names with one action tag in Struts 2

164 views Asked by At

I have a method ajouterModifierClient() in my action class pl.admin.HomeAction that handles both operations, the add operation and the update operation.

How to map two disctinct action names in on single action tag.

Here is my wanted result:

<action name="{ajouter,modifier}-client" class="pl.admin.HomeAction" method="ajouterModifierClient">
    <result name="success">ajouterModifierClient.jsp</result>
</action>
1

There are 1 answers

0
Roman C On

You can use pattern matcher regex:

<constant name="struts.patternMatcher" value="regex" />

<action name="{(ajouter|modifier)}-client" class="pl.admin.HomeAction" method="ajouterModifierClient">
    <result name="success">ajouterModifierClient.jsp</result>
</action>