Using JS to simulate struts2 of multiple action calls example _javascript tips

Source: Internet
Author: User

Recently repaired a few struts2.1 upgrade to 2.3 after the dynamic method call failed bug, deep feeling,

But my original method has a limitation, that is, the action written in submit does not work, even if the launch of dynamic method calls also not (I think it should be a bug struts2.3), so in order to improve this function, here I say a JS method.

In <s:submit value= "Submit" onclick= "return submitaction (' So-and-so action ')"/>, add the OnClick method, and then write in JS:

Copy Code code as follows:

function Submitaction (actionname) {
Document.form's name.action = actionname+ ". Action";
return true;
}

Or is <s:submit value= "Submit" onclick= "submitaction (' So-and-so action ')"/>, pay attention to one less return word, and then write in JS:
Copy Code code as follows:

function Submitaction (actionname) {
Document.form's name.action = actionname+ ". Action";
Document.form of Name.submit ();
}

Now Struts2 dynamic method calls are basically perfect, welcome comments to Add.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.