JSP跳转åå¼¹åºæ示æ¡çé®é¢çå®ç°ï¼
æ¹å¼1ï¼ JSPå端
<script type="text/javascript" language="javascript">
alert("æ¨è¿æ²¡æç»å½ï¼è¯·ç»å½...");
window.document.location.href="userlogin.html";
</script>
æ¹å¼2ï¼ Javaåå°
public void popAlert() {
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
out.print("<script>alert('æ¨è¿æ²¡æç»å½ï¼è¯·ç»å½...'); window.location='userlogin.html' </script>");
out.flush();
out.close();
}
æ¹å¼3ï¼ Javaåå° + JSPå端
1ï¼ Javaåå°ä»£ç 段
public void popAlert() {
request.setAttribute("loginError", "æ¨è¿æ²¡æç»å½ï¼è¯·ç»å½..."); // 设置é误å±æ§
request.getRequestDispatcher("userlogin.html").forward(request, response);
}
2ï¼ JSPå端代ç 段
<%
String errorInfo = (String)request.getAttribute("loginError"); // è·åé误å±æ§
if(errorInfo != null) {
%>
<script type="text/javascript" language="javascript">
alert("<%=errorInfo%>"); // å¼¹åºé误信æ¯
window.location='userlogin.html' ; // 跳转å°ç»å½çé¢
</script>
<%
}
%>
温馨提示:答案为网友推荐,仅供参考