基本上,我的问题很简单,但它需要一个了解Struts1.1并且还活着的人。
我尝试构建的伪代码如下所示:
IF element.method1 = true THEN
IF element.method2 = true THEN
COLOR.GREEN, PRINT element.prop1
ELSE
COLOR.RED, PRINT element.prop1
END
ELSE
COLOR.BLACK, PRINT element.prop1
END整个事情都会在一个迭代中发生。因此,以下是目前正在运行但尚未实现的目标:
<nested:equal property="method1" value="true">
<nested:write property="prop1" />
</nested:equal>
<nested:notEqual property="method1" value="true">
<nested:write property="prop1" />
</nested:notEqual>现在真正让我抓狂的是,这也是可行的:
<nested:equal property="method1" value="true">
<nested:equal property="method2" value="true">
</nested:equal>
</nested:equal>
<nested:notEqual property="method1" value="true">
<nested:write property="prop1" />
</nested:notEqual>但是,每当我在两个内部nested:equal标记之间插入一些东西时,它就不能编译。
因此,我的最终解决方案(见下文)将不会编译出现问题的"Missing Endtag for nested:write."
<nested:equal property="method1" value="true">
<nested:equal property="method2" value="true">
<nested:write property="element.prop1" />
</nested:equal>
</nested:equal>
<nested:notEqual property="method1" value="true">
<nested:write property="element.prop1" />
</nested:notEqual>大约4个小时后,我仍然不知道如何处理这一点,所以任何建议都会非常感谢,甚至在这篇文章发表两周后也会有所帮助,因为我的下一步是深入研究Struts1.1文档。
发布于 2013-07-19 23:52:10
虽然Roman C的解决方案工作得很好,但我也设法将其与嵌套标记组合在一起。
不幸的是,我不被允许发布原始源代码,但这就是它现在是如何工作的:
<nested:form action="/someReq" styleClass="standard">
<nested:present property="myBean.genList">
<nested:iterate property="myBean.genList" indexId="index">
<nested:equal property="method1" value="true">
<nested:equal property="method2" value="true">
<strong class="green">
<nested:write property="prop1" />
</strong>
</nested:equal>
<nested:notEqual property="method2" value="true">
<strong class="red">
<nested:write property="prop1" />
</strong>
</nested:notEqual>
</nested:equal>
<nested:notEqual property="method1" value="true">
<nested:write property="prop1" />
</nested:notEqual>
</nested:iterate>
</nested:present>
</nested:form>发布于 2013-07-15 19:36:33
使用
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>代码将如下所示
<c:choose>
<c:when test="${element.method1 == true}">
<c:choose>
<c:when test="${element.method2 == true}">
<span style="color:green;"><c:out value="${element.prop1}/></span>
</c:when>
<c:otherwise>
<span style="color:red;"><c:out value="${element.prop1}/></span>
</c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
<span style="color:black;"><c:out value="${element.prop1}/></span>
</c:otherwise>
</c:choose>https://stackoverflow.com/questions/17617112
复制相似问题