Accessing value from bean:write in value attribute of logic:equal Struts

陌路散爱 提交于 2019-12-25 07:29:51

问题


I'm developing an application using Struts 1.3.10

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>

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

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>

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


回答1:


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, the JSTL exists for something like 10 years. And since then, the Struts documentation says:

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.



来源:https://stackoverflow.com/questions/14648311/accessing-value-from-beanwrite-in-value-attribute-of-logicequal-struts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!