提问人:cmb 提问时间:3/3/2023 最后编辑:Roman Ccmb 更新时间:4/3/2023 访问量:76
<sx:submit> Button 在 IE 中有效,但在 Chrome 中不执行任何操作
<sx:submit> Button works in IE, but does nothing in Chrome
问:
问题在于,使用 <sx:submit> 标签生成的表单上的“提交”按钮在 Chrome 浏览器中单击时似乎完全不执行任何操作。
jsp 页面源代码如下所示:
<%@taglib uri="/struts-tags" prefix="s" %>
<%@taglib uri="/struts-dojo-tags" prefix="sx" %>
<div>
<table>
<s:form action="myFormAction">
<thead>
<tr><th>My Form</tr></th>
</thead>
<tbody>
<tr>
<th>Value 1</th>
<td><s:property value="%{mything.Value1}" /></td>
</tr>
<tr>
<th>Text 1: </th>
<td><s:textfield name="someName" value="%{mything.SomeName}" /></td>
</tr>
<tr>
<th>Text 2: </th>
<td><s:textfield name="someName2" value="%{mything.SomeName2}" /></td>
</tr>
<tr>
<th colspan="2">
**<sx:submit cssClass="button" value="Save" executeScripts="true" />**
</th>
</tr>
</tbody>
</s:form>
</table>
</div>
我在 Chrome 中打开了开发工具并单击了按钮,因为通常当一个按钮似乎什么都不做时,实际上会抛出一个 JavaScript 错误。但似乎什么也没发生。没有错误。我将应用程序置于调试模式(在 Eclipse 2022-12 (4.26.0)、ApacheTomcat 9.0.24 中运行),并在与 Dojo 操作关联的方法上放置了一个断点,如 struts xml 文件中所指定的那样。什么也没发生。
我在Internet Explorer中打开了该应用程序,它运行良好。我检查了在IE中生成的HTML,它与Chrome中生成的HTML不同:
在 IE 中:<input class="button" id="widget_1597536618" type="submit" __doClobber__="true" __clobberAttrs__="onclick$joinpoint,onclick$joinpoint$method,onclick" dojoType="struts:Bind" executeScripts="true" ajaxAfterValidation="false" events="onclick" onclick$joinpoint$method="function(){}" onclick$joinpoint="[object Object]" value="Save" />
在 Chrome 中:<input type="submit" dojotype="struts:Bind" events="onclick" value="Save" validate="false" ajaxafterValidation="false" id="widget_832070295" class="button" executescripts="true">
所以,我不确定为什么这两件事的生成方式不同,但我知道该按钮在 IE 中工作并执行适当的代码,但它拒绝在 Chrome 中做任何事情。
编辑:我还应该补充一点,我们正在使用Struts 2.1.8。
答:
答它与 Struts 或 Chrome 无关。此表/表格式不正确。
而不是
<table>
<s:form>
<!-- etc -->
</s:form>
</table>
它需要
<s:form>
<table>
<!-- etc... -->
</table>
</s:form>
当我输入这个问题时,我突然想到这个结构有些不合适。但是这个应用程序太旧了,而且已经写了很长时间了,以至于我只是把它吹掉了,因为“这不可能是它不起作用的原因”。
所以,记住孩子们,相信你的直觉。如果您认为“这不可能是答案”,请无论如何都要检查一下。
评论