HttpSession session = request.getSession();
User loginUser = this.service.loginUser(list); User是个对象
session.setAttribute("user", loginUser);
在此存入:session.setAttribute("msg", "用户或密码错误!");
在jsp页面里的js语言里读取和移除
<script type="text/javascript">
var msg = "${sessionScope.msg}";
if(msg!=null && msg!=""){
alert(msg);
}
<%request.getSession().removeAttribute("msg");%>
</script>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<TR> <th width="20%" align="center">用户登录名</th>
<TD class="BGCgray">${sessionScope.user.ur_loginName }</TD>
</TR>
时间: 2024-10-28 09:37:00