servlet如何使jsp页面弹出删除成功对话框
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletE...
public void doPost(HttpServletRequest request,HttpServletResponse
response)
throws ServletException,IOException
{
response.setContentType("text/html; charset=gb2312");
PrintWriter out =
response.getWriter();
response.sendRedirect("/index.jsp");
out.println("<script>alert(\"删除成功!\");
</script>");
}
本我有是这样 但没弹
这是jsp和servlet 展开
response)
throws ServletException,IOException
{
response.setContentType("text/html; charset=gb2312");
PrintWriter out =
response.getWriter();
response.sendRedirect("/index.jsp");
out.println("<script>alert(\"删除成功!\");
</script>");
}
本我有是这样 但没弹
这是jsp和servlet 展开
2个回答
展开全部
直接在servlet中定义js代码:
request.setAttribute("message","<script type='text/javascript' >alert('删除成功');</script>");
this.getServletConfig().getServletContext().getRequestDispatcher("/CFRT02.jsp")
.forward(request, response);
在返回页面中获取到message信息即可。
<form>
<table>
<tr>
<TH width="10%"
style="white-space: nowrap; text-align: center; color: green"><SPAN>${message}</SPAN></TH>
</tr>
</table>
</form>
request.setAttribute("message","<script type='text/javascript' >alert('删除成功');</script>");
this.getServletConfig().getServletContext().getRequestDispatcher("/CFRT02.jsp")
.forward(request, response);
在返回页面中获取到message信息即可。
<form>
<table>
<tr>
<TH width="10%"
style="white-space: nowrap; text-align: center; color: green"><SPAN>${message}</SPAN></TH>
</tr>
</table>
</form>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询