【问题标题】:how can i get value from Struts logic : iterate tag in variable我如何从 Struts 逻辑中获取价值:在变量中迭代标记
【发布时间】:2012-09-20 10:40:18
【问题描述】:

我正在使用 struts 标记在 Jsp 中迭代 Vo,在其中我得到一个整数值

<struts_logic:iterate id="usersVO" indexId="index" name="data" type="utils.vo.UsersVO">

<td class="tabletext"><struts_bean:write name="usersVO" property="userType"/></td>

这里的 userType 是一个 int 值。 我怎样才能在

中获得这个值
<%
  int x = **here**
%>

所以我可以处理它以供显示。

或者有没有其他方法可以根据传入的 int 值显示 String 值?

【问题讨论】:

    标签: java jsp struts struts-html


    【解决方案1】:

    听起来你应该&lt;c:choose&gt;。例如:

    <c:choose>
        <c:when test="${usersVO.userType==1}">
            <p>User type is 1</p>
        </c:when>
        <c:when test="${usersVO.userType==2}">
            <p>etc</p>
        </c:when>
       <c:otherwise>
           <p>User type is unknown</p>
       </c:otherwise>
    </c:choose>
    

    【讨论】:

      【解决方案2】:

      我使用了 struts logic:equal 标签来做到这一点,它对我来说很好用

      <struts_logic:equal name="usersVO" property="userType" value="0">
         <struts_bean:message key ="usermanagement.NotAuthorization"/>                    
      </struts_logic:equal>
      <struts_logic:equal name="usersVO" property="userType" value="1">
         <struts_html:link page="/anzeige.do" paramId="authorization" paramName="usersVO" paramProperty="userName" style="text-decoration: none;">
            <struts_bean:message key ="usermanagement.Authorization" />
         </struts_html:link>
      </struts_logic:equal>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-05-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多