什么是Strut 2的Struts 1逻辑等价物:空标签?
<logic:empty name="foo">
Foo is null or the empty string
</logic:empty>
Run Code Online (Sandbox Code Playgroud)
谢谢.
没有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>
Run Code Online (Sandbox Code Playgroud)
测试依赖于短循环,因此无法通过相等性测试来更改null测试.
如果需要对此进行测试,则可能存在设计问题.通过适当的验证,你不应该有视图所依赖的未初始化的对象,但我想总有例外.