<s:if test="user.name !=''">
<div style="float: right; font-size: 15px; margin-right: 20px">
欢迎:${user.name}
<br />
<a href="logout.action" id="logout"
style="float: right; font-size: 15px; margin-right: 13">注销</a>
</div>
<br />
</s:if>
<s:else>
<a href="javascript:void(0)" id="login" onclick="popup_show();">登录</a>
</s:else>
这里的 <s:if test="user.name != null">怎么判断为空啊?我这么写怎么不对啊?

解决方案 »

  1.   

    <s:if test="${user.name} != null">试试看
      

  2.   

    ${empty user.name}
    ${not empty user.name}
      

  3.   

    你说的是struts2中的标签吧。
    <s:if test="#session.user.name !=null">
    是这样吧。
      

  4.   

    ${empty user.name}
    ${not empty user.name}
      

  5.   


    ${empty user.name}
    ${not empty user.name}
    正解
      

  6.   

    谢谢了,上次也谢谢你了,顺便问一下为什么在这里用EL表达式会不行啊???
    如<s:if test="${empty user.name}">用的时候会报错。
      

  7.   

    我知道有${empty user.name}  ${not empty user.name}用法,但是在这里我用EL表达式会报错啊。
      

  8.   

    el表达式你写错了吧
    user.name改成 
    <s:if test="${user.name!=''}"></s:if>