The implementation methods are divided into two types:
First, directly in the Background Print JS dialog box, the principle is as follows:
Response.setcontenttype ("text/html; Charset=utf-8 "); Transfer code
PrintWriter out = Response.getwriter ();
Out.flush ();
Out.println ("<script>");
Out.println (' alert (' This username already exists, please re-enter it. ');");
Out.println ("History.back ();");
Out.println ("</script>");
Return Mapping.findforward ("");
Second, in the background to store a variable message, the value is a pop-up dialog box content, in the foreground to receive this variable, first of all in the foreground page to put a hidden field, the first time the page to access the hidden field value is empty, here you need to use the OnLoad Call JS pop-up dialog box, The background content is ejected as a dialog box, as follows:
Background:
Request.setattribute ("message", "This user name does not exist, please confirm and then enter.") ");
Front desk:
<script type= "Text/javascript" >
function Checkform () {
var flag=true;
var Message=form1.message.value;
if (message!= ' null ') {
alert (message);
Flag=false;
}
return flag;
}
</script>
<body class= "Backgdcolor" onload= "Checkform ()" >
<input type= "hidden" name= "message" value= "<%=request.getattribute (" message ")%>" >
</body> Source: http://blog.163.com/yurong_1987@126/blog/static/4751786320092711596354/