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>
<%
}
%>
时间: 2024-10-13 11:33:42