1 回答

TA贡献1784条经验 获得超7个赞
您可以set attribute使用message以下内容:
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);
现在,在您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
}
希望这对你有帮助!
添加回答
举报