My Java file is:
public class MyClass {
public void method1() {
// some code
}
public void method2() {
//some code
}
public void method3() {
//some code
}
}
In my JSP page I have three HTML buttons.
If I click on button1, then only method1 will be called, if I click on button2 then only method2 will execute, and if button3, then only method3, and so on.
How can I achieve this?
解决方案
Just give the individual button elements a unique name. When pressed, the button's name is available as a request parameter the usual way like as with input elements.
You only need to make sure that the button inputs have type="submit" as in and and not type="button", which only renders a "dead" button purely fo