我的本意是用struts2的<s:if test="">标签,来判断session是否存在,存在显示 个人空间,不存在则提示 登录
页面部分代码:
<%
String name;
name=(String)session.getAttribute("myname");
%>
<s:if test="name">
<a href="http://localhost:8080/school_auction/user/login.jsp"><strong>登录</strong></a>&nbsp;|&nbsp;<a href="http://localhost:8080/school_auction/user/register.jsp" target="_blank"><strong>注册</strong></a>
</s:if>
<s:else>
您好!<%=name %>,<a href="http://localhost:8080/school_auction/user/userinfo.jsp"> 个人空间</a>
<a href="user!exits.action">安全退出</a>
</s:else>1、如果登录了,能取到session,name变量有值,jsp能输出,已经测试过
2、if标签有效,已经测试过。
3、if的test就是不能判断那个name变量。或许变量不能这么样判断吧?test里把name当一个字符串而不是一个变量?总之就是不行,望求救,我没分了,大家帮帮我