• <legend id='gok60'><style id='gok60'><dir id='gok60'><q id='gok60'></q></dir></style></legend>

        <small id='gok60'></small><noframes id='gok60'>

        <i id='gok60'><tr id='gok60'><dt id='gok60'><q id='gok60'><span id='gok60'><b id='gok60'><form id='gok60'><ins id='gok60'></ins><ul id='gok60'></ul><sub id='gok60'></sub></form><legend id='gok60'></legend><bdo id='gok60'><pre id='gok60'><center id='gok60'></center></pre></bdo></b><th id='gok60'></th></span></q></dt></tr></i><div id='gok60'><tfoot id='gok60'></tfoot><dl id='gok60'><fieldset id='gok60'></fieldset></dl></div>
          <bdo id='gok60'></bdo><ul id='gok60'></ul>

      1. <tfoot id='gok60'></tfoot>

        Struts2 s:if 测试非空值

        Struts2 s:if test for non-null value(Struts2 s:if 测试非空值)

          <i id='4qGNt'><tr id='4qGNt'><dt id='4qGNt'><q id='4qGNt'><span id='4qGNt'><b id='4qGNt'><form id='4qGNt'><ins id='4qGNt'></ins><ul id='4qGNt'></ul><sub id='4qGNt'></sub></form><legend id='4qGNt'></legend><bdo id='4qGNt'><pre id='4qGNt'><center id='4qGNt'></center></pre></bdo></b><th id='4qGNt'></th></span></q></dt></tr></i><div id='4qGNt'><tfoot id='4qGNt'></tfoot><dl id='4qGNt'><fieldset id='4qGNt'></fieldset></dl></div>
        1. <small id='4qGNt'></small><noframes id='4qGNt'>

          • <tfoot id='4qGNt'></tfoot>

                <tbody id='4qGNt'></tbody>
                <legend id='4qGNt'><style id='4qGNt'><dir id='4qGNt'><q id='4qGNt'></q></dir></style></legend>
                • <bdo id='4qGNt'></bdo><ul id='4qGNt'></ul>

                  本文介绍了Struts2 s:if 测试非空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想使用 struts2 标记测试非空值.如果我使用以下内容,这将有效:

                  I am wanting to test for a non-null value using a struts2 tag. This works if I use the following:

                  <s:if test="myObject.myField != null">..stuff..</s:if>
                  

                  如果我错过了非空部分,它似乎也可以工作,然后这样做:

                  It also seems to work if I miss out the not-null part, and just do:

                  <s:if test="myObject.myField">..stuff..</s:if>
                  

                  但是,当 myFieldString 时,这不再有效.我更喜欢第二种形式,因为它更简洁,而且看起来不像将代码放在我的表示层中.但我不想使用它,如果它是一个未记录的功能,不知何故意外工作,正如它不适用于字符串的事实所暗示的那样.

                  However, when myField is a String, this no longer works. I prefer the second form as it is more concise, and seems less like putting code in my presentation layer. But I don't want to use it if it's an undocumented feature which is somehow working by accident, as suggested by the fact that it doesn't work for strings.

                  所以我的问题是,在上述测试中错过 "!= null" 是否可以?

                  So my question is, is it ever ok to miss out "!= null" in the above test?

                  推荐答案

                  使用 <s:if test="whatsoever whatsoever 是一个应该计算的 OGNL 表达式Boolean 值,如果你希望标签正常工作.如果你的字段是 boolean 类型,没关系,在其他情况下它就不起作用.

                  Using <s:if test="whatsoever the whatsoever is an OGNL expression that should evaluate to Boolean value if you want the tag is working right. If your field is of boolean type it's ok, in other case it's just doesn't work.

                  另外,在 if tag 类型被定义为Boolean,所以它不是原始的boolean,但值可以是原始的boolean.因此,在评估测试用例时使用不同类型时要小心.

                  Also, in the documentation page for the if tag the type is defined as Boolean, so it's not primitive boolean but the value could be primitive boolean. So, be careful when using different types when evaluating the test case.

                  这篇关于Struts2 s:if 测试非空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)

                  • <bdo id='8QdyB'></bdo><ul id='8QdyB'></ul>
                      <legend id='8QdyB'><style id='8QdyB'><dir id='8QdyB'><q id='8QdyB'></q></dir></style></legend>
                    • <tfoot id='8QdyB'></tfoot>

                              <tbody id='8QdyB'></tbody>

                            <small id='8QdyB'></small><noframes id='8QdyB'>

                            <i id='8QdyB'><tr id='8QdyB'><dt id='8QdyB'><q id='8QdyB'><span id='8QdyB'><b id='8QdyB'><form id='8QdyB'><ins id='8QdyB'></ins><ul id='8QdyB'></ul><sub id='8QdyB'></sub></form><legend id='8QdyB'></legend><bdo id='8QdyB'><pre id='8QdyB'><center id='8QdyB'></center></pre></bdo></b><th id='8QdyB'></th></span></q></dt></tr></i><div id='8QdyB'><tfoot id='8QdyB'></tfoot><dl id='8QdyB'><fieldset id='8QdyB'></fieldset></dl></div>