Struts2: multiple submit button

只愿长相守 提交于 2019-11-28 12:45:17

If you are using struts in a version newer than 2.3.15.2, you must add this constant to struts.xml to enable the action: prefix:

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

because it has been disabled by default.

Read more on Security Bullettin S2-018.

You need to map the "names" of the actions to the actual Action classes you created. If you follow the example and have the struts.xml file like:

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

When you click on the input generated by <s:submit value="Submit"/> Struts2 will execute your execute method in your MySubmitAction. When you click on the input generated by <s:submit value="Clear" action="myClearAction"/> struts2 is supposed to override the default action specified by the s:form tag (I haven't tested it) and will execute the execute method in your MyClearAction.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!