Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 jsp 文件来显示错误消息
取决于错误字符串是否为空。
<s:if test="{!''.equals(errorMsg)}"> <div class="errors"><s:property value="errorMsg"/></div> </s:if>
但是无论 errorMsg 是什么,div 部分总是在那里,为什么?如何解决这个问题?
使用!=:
!=
<s:if test='%{errorMsg != ""}'> ...
虽然如果它可以为空,您也应该检查它(引用本身是否为false空)。
false
您正在构建一个包含条件值的立即列表。
要么使用%{}它,要么完全不使用它。
%{}
请注意,您也可以将错误直接添加到操作中。