弹出提示对话框并重定向网页
2018-08-19 本文已影响0人
神坛下的我
Util.java
public class Util {
private String dialogStr;//弹出对话框的代码
private String message;//弹出的提示信息
private String url;//重定向的链接地址
public String getDialogStr() {
dialogStr="<script language='javascript'>\r\n\t";
dialogStr+="alert('"+message+"');\r\n\t";
dialogStr+="window.location.href='"+url+"';\r\n";
dialogStr+="</script>";
return dialogStr;
}
public void setDialogStr(String dialogStr) {
this.dialogStr = dialogStr;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
index.jsp
<form action="result.jsp" method="post">
<table>
<tr>
<td align="right">请输入用户名:</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td align="right">请输入密码:</td>
<td><input type="password" name="pwd" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登录"/></td>
</tr>
</table>
</form>
result.jsp
<jsp:useBean id="popdialog" class="com.count.Util"></jsp:useBean>
<jsp:setProperty property="message" name="popdialog" value="注册成功!"/>
<jsp:setProperty property="url" name="popdialog" value="index.jsp"/>
<jsp:getProperty property="dialogStr" name="popdialog"/>
捕获.PNG