【发布时间】:2013-07-12 14:20:01
【问题描述】:
基本上,我的问题很简单,但它需要知道 Struts 1.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 小时后,我仍然不知道如何处理这个问题,所以任何建议都会非常感激,甚至在这篇文章发布 2 周后也会有所帮助,因为我的下一步是深入研究 Struts 1.1 文档。
【问题讨论】:
-
你为什么用嵌套,你对EL失望吗?
-
完全没有,不幸的是,我不允许在我当前维护的遗留系统中使用任何“尚未使用”的技术。
-
好吧,我再次检查了项目文件。在每个 JSP 中都有以下行: 在相应的文件中包含 tags-tiles、tags-html、tags-logic、tags-bean 和 tags-nested。 . 我说得对吗?我现在可以使用 EL 了吗?
-
用EL,很简单,不用写
nested标签。您也可以使用 JSTL 代替 Struts1 标签,这是迁移到新版 Struts 的一大步。 -
此外,Struts 1.3.10 通过 contrib 在其发行版中支持 EL 和 JSTL。
标签: java jsp struts nested equals