struts 2 火狐浏览器
我有一个使用 struts 2 的应用程序。我的问题是每当我使用 IE 时,我都会从 HTML 页面到操作类获得很好的属性值,但是当我使用 firefox 时,我会得到一个 null 值。
我使用 javascript 动态创建文本区域,在其中映射操作类属性“解释”的值。
function showExplain(){
if(document.getElementById("equivalentExp").checked){
document.getElementById('explaintxt').style.display = "inline";
var taspan = document.getElementById("taSpan");
var ta = document.createElement('textarea');
ta.setAttribute("name", "explanation");
ta.setAttribute("id", "explanation");
ta.setAttribute("cols", "45");
ta.setAttribute("rows", "5");
ta.setAttribute("class", "textAreaField");
ta.innerHTML = '<%if(explanation != null){%><%= explanation %><%}%>';
taspan.appendChild(ta);
}else{
document.getElementById('explaintxt').style.display = "none";
if(document.getElementById("explanation") != null){
var taspan = document.getElementById("taSpan");
taspan.removeChild(document.getElementById("explanation"));
}
}
}
我的操作类中有“解释”属性的 getter/setter,所以我知道这不是问题。我还尝试alert("document.getElementById("explanation").value);并且它在IE和Firefox中显示我的文本区域中的正确值,但是当它到达控制器时,它是空的使用 firefox。
我也尝试只使用 html 中声明的常规文本区域,它在两种浏览器中都可以正常工作,
令人困惑的是为什么在提交表单之前,该值没有到达我的操作类。当我尝试显示它时,我有正确的值
,有人对此有答案吗
?
I have an application that uses struts 2. My problem is whenever I'm using IE, I get the attribute value fine from my HTML page to my action class, but when I use firefox, I'm getting a null value.
I'm using javascript to dynamically create the textarea where I map the value of my action class attribute "explanation".
function showExplain(){
if(document.getElementById("equivalentExp").checked){
document.getElementById('explaintxt').style.display = "inline";
var taspan = document.getElementById("taSpan");
var ta = document.createElement('textarea');
ta.setAttribute("name", "explanation");
ta.setAttribute("id", "explanation");
ta.setAttribute("cols", "45");
ta.setAttribute("rows", "5");
ta.setAttribute("class", "textAreaField");
ta.innerHTML = '<%if(explanation != null){%><%= explanation %><%}%>';
taspan.appendChild(ta);
}else{
document.getElementById('explaintxt').style.display = "none";
if(document.getElementById("explanation") != null){
var taspan = document.getElementById("taSpan");
taspan.removeChild(document.getElementById("explanation"));
}
}
}
I have my getter/setter for the "explanation" attribute in my action class, so I know that's not the problem. I also tried to alert("document.getElementById("explanation").value); and it's displaying the right value that I have in my textarea, both in IE and firefox, but when it get to the controller, it's null when I use firefox.
I also tried to just use a regular textarea declared in the html, it works fine in both browsers.
What's confusing is why doesn't the value reach my action class, when, before submitting the form, I have the right value when I try to display it.
I'm stuck, does anyone have an answer to this?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论