1.在Action中添加
if(isValid)
{
session.setAttribute("username",username);
log.info("User"+username+"login.");
}
else
{
errors.add(ActionErrors.GLOBAL_MESSAGE,new ActionMessage("login.message.failed"));
}
2.在jsp中添加
<html:errors property="org.apache.struts.action.GLOBAL_MESSAGE"/>
本文介绍了一个基于Struts框架实现的简单登录验证流程。在Action中实现了登录逻辑判断,并通过设置session来记录用户状态。若登录失败,则会在页面上显示错误信息。此外,还展示了如何在JSP页面中展示全局错误消息。
693

被折叠的 条评论
为什么被折叠?



