从bean访问值:写入逻辑:等于Struts的value属性 [英] Accessing value from bean:write in value attribute of logic:equal Struts

查看:72
本文介绍了从bean访问值:写入逻辑:等于Struts的value属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Struts 1.3.10开发应用程序

I'm developing an application using Struts 1.3.10

我需要迭代2个列表才能在jsp中打印结果.需要使用第一次列表迭代来从列表2中选择元素.因此,我试图这样做:

I need to iterate 2 lists in order to print the result in jsp. The first list iteration needs to be used to select elements from list 2. For that reason I'm trying to do like this:

 <logic:iterate name="bodyForm" property="domainList" id="domList">
     <div><h1><bean:write name="domList" property="domain"/><h1>
          <ul> <logic:iterate name="bodyForm" property="locationsList" id="locList" >
                   <logic:equal name="locList" property="domain" value="<bean:write name="domList" property="domain"/>" >
                       <li><div>....</div></li>
                   <logic:equal>
               </logic:iterate>
           </ul>
     </div>
</logic:iterate>

但是,当我在"logic:equal"的内部值中调用"bean:write"时,出现错误. 你知道如何解决吗?

But, when I call "bean:write" inside value of "logic:equal" I get an error. Do you know how to solve it?

当您向我示意时,我已经使用JSTL标记来获取解决方案,但是在网页的源代码中,我得到了以下结果:

As you sugest me I have used JSTL tags to get the solution, but in the source code of the web page I have this result:

    <h1>domList.domain</h1>
        <ul>
          <li class="grey">
             <div>locList.countries.name </div>
             <div>locList.name</div>
             <div>locList.hostname</div>
             <div>locList.ip</div>
          </li>
          <li class="">
             <div>locList.countries.name </div>
             <div>locList.name</div>
             <div>locList.hostname</div>
             <div>locList.ip</div>
          </li>
        </ul>

我似乎不是在读取bean信息...知道吗?

I seems that is not reading the bean information... Any idea?

推荐答案

学习JSTL和JSP EL,并使用它们代替这些过时的struts标记:

Learn the JSTL and the JSP EL, and use it instead of these obsolete struts tags:

<c:forEach var="domList" items="${bodyForm.domainList}">
    <div>
        <h1><c:out value="${domList.domain}"/><h1>
        <ul> 
            <c:forEach var="locList" items="${bodyForm.locationsList}">
                <c:if test="${locList.domain == domList.domain}">
                    <li><div>....</div></li>
                </c:if>
           </c:forEach>
       </ul>
    </div>
</c:forEach>

AFAIR,JSTL存在了大约10年.从那时起, Struts文档说:

AFAIR, the JSTL exists for something like 10 years. And since then, the Struts documentation says:

注意:-该标签库中的许多功能在JavaServer Pages标准标签库(JSTL)中也可用. Apache Struts组鼓励在可能的情况下在Struts特定标签上使用标准标签.

Note: - Many of the features in this taglib are also available in the JavaServer Pages Standard Tag Library (JSTL). The Apache Struts group encourages the use of the standard tags over the Struts specific tags when possible.

这篇关于从bean访问值:写入逻辑:等于Struts的value属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆