Question

What is the attribute method in the action tag in the struts.xml? I have seen a lot of usage cases of this attribute but I don't understand how it changes the behaviour?

For example I see nothing happens when I change the following method attribute or I remove it. I tried execute and input and {1}. Why sometimes I see {1} for this attribute of struts.xml files.

<action name="ShowAddItemPage" method="input" class="action.clerk.ShowAddItemPage">
  <result name="success" type="tiles">addItem</result>
  <result name="generalError" type="tiles">clerkGeneralError</result>
  <result name="input" type="tiles">addItem</result>
</action>
Was it helpful?

Solution

According to this the attribute method in action tag is used to specify the method name that will handle the action-logic when the corresponding action is called.

The behavior is as: When any action is called, struts.xml is looked up for that action. If method attribute is specified then that method will be executed in the action class, if no method attribute is specified then by default execute() is called. And If there is no execute method and no other method specified in the configuration the framework will throw an exception.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top