gpt4 book ai didi

struts2 - Struts 2 相当于 Struts 1 逻辑 :empty tag? 是什么

转载 作者:行者123 更新时间:2023-12-02 14:08:56 25 4
gpt4 key购买 nike

Struts 2 中 Struts 1 的逻辑:空标记的等价物是什么?

<logic:empty name="foo">
Foo is null or the empty string
</logic:empty>

谢谢。

最佳答案

没有 struts2 标签可以做到这一点,OGNL 比 struts1 标签有更多的可能性和更多的表现力,但是似乎没有一种方法可以简洁地检查字符串是否为 null 和空字符串。

以下作品:

<s:if test="(myString == null || myString.equals(''))">
myString is blank or null
</s:if>
<s:else>
The value is <s:property value="myString"/>
</s:else>

该测试依赖于短路,因此 null 测试不能与相等测试一起更改。

如果经常需要对此进行测试,则可能存在设计问题。通过适当的验证,您不应该拥有 View 所依赖的未初始化对象,但我认为总是有异常(exception)。

关于struts2 - Struts 2 相当于 Struts 1 逻辑 :empty tag? 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com