if(studentname.equals("小紅")&&xh.equals("123")){
session.setAttribute("studentname",?studentname);
session.setAttribute("xh",?xh);
response.sendRedirect("sucess.jsp");
}else{
response.sendRedirect("login.jsp");
out.print("<script>alert('輸入錯誤!');</script>");
}
這樣寫的話網頁會報錯IF那一行有錯誤
if(studentname.equals("小紅")&&xh.equals("123")){
session.setAttribute("studentname",?studentname);
session.setAttribute("xh",?xh);
response.sendRedirect("sucess.jsp");
}else{
out.print("<script>location.href='index.jsp';alert('輸入錯誤!');</script>");
}
把else里面的重定向換掉用JS里面的跳轉就能正常跳轉,這是為什么?在執行代碼時,不是應該先執行JAVA代碼在專
頁面對JS進行解析嗎,為什么第一個不行呢?
JSP重定向的問題
qq_PureBLACK_13313525
2017-02-28 18:26:10