天猫学习总结

今天对于ssm整合思考一个问题,就是前端这个用户登入显示
在这里插入图片描述
没有登入时又显示
在这里插入图片描述
是如何实现这个功能的

<c:if test="${!empty user}">
	<a href="loginPage">${user.name}</a>
	<a href="forelogout">退出</a>
</c:if>

<c:if test="${empty user}">
	<a href="loginPage">请登录</a>
	<a href="registerPage">免费注册</a>
</c:if>

通过上面代码就实现了

之后还想到个问题页面跳转时用户是如何保存可以不消失的,因为如果用的是model.addattribute()是在request中,页面一跳转就消失了,看代码是在session中
在这里插入图片描述
这样在session中就可以保存了。

猜你喜欢

转载自blog.csdn.net/qq_16930699/article/details/85269522
今日推荐