在java中传递空参数(被解析为没有得到任何agrument al all)(Pass empty argument in java (to be parsed as not getting any agrument al all))
我想知道在java中是否有任何方法将参数传递给java实际读取的方法,因为根本没有得到任何参数。 更具体:我有一个方法的两个版本,一个需要一个参数,另一个根本没有。 因此,在没有参数的情况下调用该方法时,将执行第二个版本。 有没有办法实际传递一个空读参数,其中java读取根本没有提供参数?
void exampleMethod(){ // do stuff } void exampleMethod(arg){ // do other stuff }
我想能打电话
exampleMethod(?);
这样就调用了该方法的第一个版本。
I was wondering if there is any way in java to pass an argument to a method which is actually read by java as not getting any argument at all. More concrete: I have got two versions of a method, one requiring one argument and the other none at all. So when the method is called without an argument the second version is executed. Is there a way to actually pass an empty argument which java reads as not being provided with an argument at all?
void exampleMethod(){ // do stuff } void exampleMethod(arg){ // do other stuff }
I would like to be able to call
exampleMethod(?);
So that the first version of the method is called.
原文:https://stackoverflow.com/questions/28384201
最满意答案
发现问题:
包装节点未正确关闭。
<div att1="value" att2="value" <div id="header-text">...</div> </div>
AFAIK,FF和IE礼貌地修复了标签......但是Opera没有,因此孩子DIV实际上不是DOM中的元素。
应该工作正常。 id为“header-text”的元素是什么? 您确定只有一个匹配项,并且它具有可编辑的内容吗?
你可以发布一些标记,以便我们测试吗?
从PPK的网站,似乎没有任何Opera问题: http : //www.quirksmode.org/dom/innerhtml.html
更新:在XP上的Opera 9.6.4中运行此代码对我来说很好。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>innerHTML test</title> <script> function doIt(){ document.getElementById("header-text").innerHTML = "something interesting"; } </script> </head> <body> <div id="header-text" class="picture-text"> Static text </div> <input type="button" value="Change It" onclick="doIt();"/><br/> </body> </html>
FOUND THE ISSUE:
The wrapping node was not properly closed.
<div att1="value" att2="value" <div id="header-text">...</div> </div>
AFAIK, FF and IE were politely fixing the tag... but Opera wasn't, thus the child DIV wasn't really an element in the DOM.
Should work fine. What is the element with the id "header-text"? Are you sure there is only one match, and it has editable content?
Can you post some of the markup so we can test?
From PPK's site, there doesn't seem to be any Opera issues: http://www.quirksmode.org/dom/innerhtml.html
Update: Running this code in Opera 9.6.4 on XP works fine for me.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>innerHTML test</title> <script> function doIt(){ document.getElementById("header-text").innerHTML = "something interesting"; } </script> </head> <body> <div id="header-text" class="picture-text"> Static text </div> <input type="button" value="Change It" onclick="doIt();"/><br/> </body> </html>
相关问答
更多-
.innerHTML歌剧问题?(.innerHTML opera issue?)[2022-05-08]
发现问题: 包装节点未正确关闭。AFAIK,FF和IE礼貌地修复了标签......但是Opera没有,因此孩子DIV实际上不是DOM中的元素。 应该工作正常。 id为“header-text”的元素是什么? 您确定只有一个匹配项,并且它具有可编辑的内容吗? 你可以发布一些标记,以便我们测试吗? 从PPK的网站,似乎没有任何Opera问题: http : //ww ......