Implement j2eeaction in the background action of J2EE to control the front-end javascript pop-up dialog box
1. In the background Action:
Request. setAttribute ("message", "this user name or password is incorrect. Please enter a new one! ");
2. Front-end jsp page:
2.1 Add the onload method to the <body> label, for example, <BODY topmargin = "0" leftmargin = "0" onload = "checkForm ()">
2.2 Add the js Code block to the jsp page as follows:
<! -- Dialog box: the user name or password is incorrect. Please enter a new one! -->
<Script type = "text/javascript">
Function checkForm (){
Var flag = '<% = request. getAttribute ("message") %> ';
If (flag! = "Null "){
Alert (flag );
/* Clear the value in the <input> label
$ ("# Name"). attr ("value ","");
$ ("# Password"). attr ("value ","");
*/
}
}
</Script>
Conclusion: The error message is put into the message in the background, and the js Code Execution dialog box is displayed in the front-end jsp by investigating the onload method.
After the Foreground Data is submitted to the action, after the action is processed, a dialog box is displayed in javascript, prompting that the operation is successful.
Use ajax .. You can search for it online. Jquery ajax. Very simple. You can call the return value to the interface as long as the uri of the action is correct ..
How does JAVA pop up the JS dialog box in action ??
Because return is returned. Change to return null. Try again.