Struts2: multiple submit buttons

I would like to have 2 submit buttons in my jsp, so I found this tutorial: http://struts.apache.org/release/2.3.x/docs/multiple-submit-buttons.html I want to develop a Nyong Nyong solution with a class MyBaseAction, an extended class of MySubmitAction and MyClearAction. But I can’t make it work. I'm not sure what jsp will be like, this is in the example:

<s:form method="post" action="mySubmitAction">
    <s:submit value="Submit"/>
    <s:submit value="Clear" action="myClearAction"/>
</form>

But I believe that he referred to the previous example. I'm also not sure about struts.xml, do I need to set a specific constant value or something else?

It would be great if someone could provide a complete example of jsp and struts.xml.

+3
source share
2

, 2.3.15.2, struts.xml , action: :

<constant name="struts.mapper.action.prefix.enabled" value="true" />

.

S2-018.

+11

"" Action, . struts.xml, :

<action name="mySubmitAction" class="MySubmitAction">
       <result>submit.jsp</result>
</action>
<action name="myClearAction" class="MyClearAction">
       <result>submit.jsp</result>
</action>

, <s:submit value="Submit"/>, Struts2 execute MySubmitAction. , <s:submit value="Clear" action="myClearAction"/> struts2 , s:form ( ) execute MyClearAction.

+1

All Articles