1 回答

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超7個(gè)贊
您可以set attribute使用message以下內(nèi)容:
String msg= "Sorry !! You have an error";
request.getSession().setAttribute("msg", msg);//setting attribute
// forwards message to your page
request.getRequestDispatcher("yourloginpage").forward(request,response);
現(xiàn)在,在您login page的表格頂部寫下如下所示:
HttpSession session = request.getSession();//getting session
String msg;
//checking if msg is not null
if(session.getAttribute("msg")!=null){
msg= (String)session.getAttribute("msg");
out.println("<p style='color:green;'> "+msg+"</p>"); //printing message
}
希望這對你有幫助!
添加回答
舉報(bào)