ssh里jsp调用action方法,若不成功怎么在页面弹出框提示失败?
2个回答
展开全部
你在Action方法里面判断,如果不成功转发到相应的页面或者返回HTML标签及脚本直接输出。
转发:
request.getRequestDispatcher("/aaa/bbb.shtml").forward(request, response);
直接输出:
PrintWriter out = response.getWriter();
out.print("<script>alert('转发成功!')</script>");
out.print("<script>window.location.href='stuaction.action'</script>");
out.flush();
out.close();
return null;
转发:
request.getRequestDispatcher("/aaa/bbb.shtml").forward(request, response);
直接输出:
PrintWriter out = response.getWriter();
out.print("<script>alert('转发成功!')</script>");
out.print("<script>window.location.href='stuaction.action'</script>");
out.flush();
out.close();
return null;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询