后台在sesson中保存Order对象,其中有属性kind。1为发货类别,2为借用类别。
前台页面根据kind类型来显示内容。
页面代码如下:
<s:if test="${Order.kind} ==1">发货</s:if>
<s:else>借用</s:else>执行时总是提示错误attribute value does not accept any expressions错误。
改用:
<s:if test="%{Order.kind} ==1">发货</s:if>
<s:else>借用</s:else>仍不生效,总是显示借用。求大神指导test表达式到底如何写<s:if>struts2

解决方案 »

  1.   

    <s:if test="${Order.kind eq '1'}">发货</s:if>
      

  2.   


    试了下,仍然不对,仍报According to TLD or attribute directive in tag file, attribute test does not accept any expressions错误。我页面只引用了struts 标签
    <%@ taglib prefix="s" uri="/struts-tags"%>
    会不会和这个有关系
      

  3.   

    <s:if test="#Order.kind == '1'">发货</s:if>
      

  4.   

    struts标签和el表达式不能结合使用的,如果你这个放在session中你可以试试<s:if test="%{#session.Order.kind} ==1">发货</s:if>如果是request里面就<s:if test="%{#request.Order.kind} ==1">发货</s:if>看看是否可以成功!
      

  5.   

    按照你的思路我已经搞定,多谢!正解是:<s:if test="%{#session.order.kind ==1}">发货</s:if>