标签:
if(dg.addmes(title,forumname,pdate,cont)){
//成功 此处向request中添加一个参数
request.setAttribute("str", "true");
request.getRequestDispatcher("suc.jsp").forward(request, response);
}else{
//失败
此处向request中添加一个参数
request.setAttribute("str", false");
request.getRequestDispatcher("lostcid.jsp").forward(request, response);
}
suc.jsp页面的body体中添加语句
<%
if ((String)request.getAttribute("str") == "true") {
%>
<script>
alert("操作成功!");
</script>
<%
}
%>
lostcid.jsp页面的body体中添加语句
<%
if ((String)request.getAttribute("str") == "false") {
%>
<script>
alert("操作失败!");
</script>
<%
}
%>
在JSP中,当添加信息成功后跳转回主页面并弹出操作成功提示框
标签:
原文地址:http://www.cnblogs.com/outlooking/p/4265689.html