What is the meaning of method = "{1}" in action configuration?

1.4k views Asked by At

There is a project download from network, in its structs.xml, there is action configuration:

<action name="elecMenuAction_*" class="elecMenuAction" method="{1}">
    <result name="menuHome">/WEB-INF/page/menu/home.jsp</result>
</action>

I don't know the method="{1}" mean, how to understand the mean?

2

There are 2 answers

0
Pooja Arora On

This link can be useful in understanding the above syntax Struts2, best practice for using method={1}

0
aircraft On

If there is method="{number}", corresponding, the action config should have * in its name,

Example:

<action name="user_*" class="UserAction" method="{1}">

and in its corresponding jsp if has a form :

In that way, structs will let the user_userLogin action according to the user_*’s format analysis, and take out the * according the number 1, 2, 3 …, 1 means the first *.

If the action config like this:

<action name="user_*_*" class="com.xyz.{1}Action" method="{2}">

and the jsp form is like this:

<form action="user_Login_userLogin" method="post">

Its action will become like this:

class="com.xyz.Login" method="{userLogin}"