<tfoot id='JqTGm'></tfoot>

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

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

        headerKey=“-1"有什么问题?

        时间:2023-09-24
        <tfoot id='vnxt8'></tfoot>
          <bdo id='vnxt8'></bdo><ul id='vnxt8'></ul>
            <tbody id='vnxt8'></tbody>

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

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

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

                • 本文介绍了headerKey=“-1"有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有什么问题:

                  <s:select list="fruits" name="fruitSelect" id="fruitSelect"
                  listKey="fid" listValue="fname" headerKey="-1" headerValue="Pick a fruit!" />
                  

                  大量在线示例使用此值:http://www.coderanch.com/t/439139/Struts/wrong-selecthttp://www.mkyong.com/struts2/struts-2-sselect-drop-down-box-example/

                  Plenty of online examples use this value: http://www.coderanch.com/t/439139/Struts/wrong-select http://www.mkyong.com/struts2/struts-2-sselect-drop-down-box-example/

                  但是实际的文档(你可以通过将鼠标悬停在符号上来查看 Eclipse 的工具提示)说

                  BUT the actual documentation (you can view this on the tooltip in Eclipse by hovering over the symbol) says

                  列表中第一项的键.不能为空!'-1' 和 '' 是正确的, '' 是不好.

                  Key for first item in list. Must not be empty! '-1' and '' is correct, '' is bad.

                  -1 对我来说似乎很合乎逻辑,无论如何它不应该是一个有效的选项.是正确的,"对我来说没有任何意义,所以我不太担心.

                  -1 seems pretty logical to me and it shouldn't be a valid option anyway. " is correct, " doesn't make sense on any level to me so I am not too concerned by it.

                  推荐答案

                  key没有问题,但是docs可能有点问题:-1是整数key,'-1' 是字符串,'' 是空字符,"" 是空字符串,但key 不能为空.因此 -1'-1'' '" " 是有效值.来自文档:

                  Nothing wrong with the key but may be a little bit with docs: -1 is an integer key, '-1' is a string, '' is an empty char, "" is an empty string, but the key should not be empty. Thus -1, '-1', ' ', " " are valid values. From the docs:

                  '1' 是一个字符,'01' 是一个字符串,1"是一个字符串.这很重要,因为如果value"属性返回的值与list"属性中的键类型不同,它们将不匹配,即使它们的字符串值可能相同.如果它们不匹配,则列表中没有任何内容将被自动选中.

                  '1' is a char, '01' is a String, "1" is a String. This is important since if the value returned by your "value" attribute is NOT the same type as the key in the "list" attribute, they WILL NOT MATCH, even though their String values may be equivalent. If they don't match, nothing in your list will be auto-selected.

                  您应该为 listKey 属性提供相应的字段类型,因此 -1 是用于数字类型的整数,而不是 ' '" " 用于字符和字符串类型.

                  You should provide to the listKey attribute a corresponding field type, so -1 is for integer of numeric types, rather than ' ' and " " are for character and string types.

                  框架在比较 select 标记的键和值时使用类型转换,为了避免在 OGNL 运行时某处发生类型转换错误,您最好提供正确的类型,并且两个关键属性有同一类型.如果不应该为空的键值与两个属性中指定的值匹配,则将填充标题值选项.

                  The framework uses a type conversion when comparing keys and values of the select tag and to avoid a typecast errors occurred somewhere at the OGNL runtime you'd better provide the type correctly and two key attributes have the same type. And if the key value, which should be not empty, matches the value specified in the both attributes the header value option will be populated.

                  这篇关于headerKey=“-1"有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Struts2 ValueStack 如何处理多个请求 下一篇:Struts2 + 完整的 Hibernate 插件 -->会话已关闭?

                  相关文章

                      <small id='9ZlLm'></small><noframes id='9ZlLm'>

                      <legend id='9ZlLm'><style id='9ZlLm'><dir id='9ZlLm'><q id='9ZlLm'></q></dir></style></legend>
                    1. <tfoot id='9ZlLm'></tfoot>
                      <i id='9ZlLm'><tr id='9ZlLm'><dt id='9ZlLm'><q id='9ZlLm'><span id='9ZlLm'><b id='9ZlLm'><form id='9ZlLm'><ins id='9ZlLm'></ins><ul id='9ZlLm'></ul><sub id='9ZlLm'></sub></form><legend id='9ZlLm'></legend><bdo id='9ZlLm'><pre id='9ZlLm'><center id='9ZlLm'></center></pre></bdo></b><th id='9ZlLm'></th></span></q></dt></tr></i><div id='9ZlLm'><tfoot id='9ZlLm'></tfoot><dl id='9ZlLm'><fieldset id='9ZlLm'></fieldset></dl></div>
                        <bdo id='9ZlLm'></bdo><ul id='9ZlLm'></ul>