Struts - Using multiple submit buttons for one form? (How to know which was clicked)

怎甘沉沦 提交于 2019-12-06 11:34:37
Anthony Grist

Use the property attribute on your <html:submit> tag to specify the name of the request parameter that you'll check in your action.

JSP

<html:submit property="back">back</html:submit>

Action

if(request.getParameter("back") != null) {
    // back button was clicked
}

You can, alternatively, give all of your submit buttons the same property, then check the value of the parameter in your action. However, that adds additional internationalization concerns (you'd need to check for non-English translations of the same string).

For more information, see the Struts API.

Either use DispatchAction or use javascript and pass value actontype in hidden parameter (back,continue later).

http://unnisworld.wordpress.com/2008/02/14/struts-tip-how-to-organize-related-operations-into-a-single-action-class/

you can get press button id by jquery. Then you know which button has clicked. According to Click button Call struts Action.

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