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('輸入錯(cuò)誤!');</script>");
}
這樣寫的話網(wǎng)頁(yè)會(huì)報(bào)錯(cuò)IF那一行有錯(cuò)誤
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('輸入錯(cuò)誤!');</script>");
}
把else里面的重定向換掉用JS里面的跳轉(zhuǎn)就能正常跳轉(zhuǎn),這是為什么?在執(zhí)行代碼時(shí),不是應(yīng)該先執(zhí)行JAVA代碼在專
頁(yè)面對(duì)JS進(jìn)行解析嗎,為什么第一個(gè)不行呢?
JSP重定向的問(wèn)題
qq_PureBLACK_13313525
2017-02-28 18:26:10