繁体   English   中英

取消按钮在Firefox和Chrome中的行为有所不同

[英]Cancel button behaves differently in Firefox and in Chrome

注意:几个小时后,我也在Javaranch中发布了这个问题。 相应的链接是http://www.coderanch.com/t/629456/JSP/java/Cancel-button-behaves-differently-Chrome 我还没有收到回复。 我将其张贴在这里,看看是否能得到一两个建议。 另外,我在Struts和JSP方面还是一个初学者,所以请告知我是否应该提供更多详细信息。

问题是我的网页上的“取消”按钮在chrome浏览器和Firefox浏览器中的行为不同。

我当前的URL是context path / importEmployee.do?method = load。

在当前页面中,我上传了一个CSV文件。 该页面有两个按钮-确定和取消,而这些按钮正是我遇到的麻烦(稍后我会介绍该部分)。 相关的JSP部分如下。

 <html:form action="importEmployee?method=save" method="POST" styleId="importEmployee" enctype="multipart/form-data"> ....... some headers and title bar and stuff... and then as follows. <div class="contentSection"> <table border="0" class="formTable"> <html:hidden property = "selectedSet" /> <tr> <td class="formLabel"><label for="file">Download File:</label> </td> <td> <span> <a class="buttonStyle" rel="nofollow">Download Sample CSV</a> </span> </td> <tr> <td class="spacerCell"> </td> </tr> <tr> <td class="formLabel"><label for="file">CSV File:</label></td> <td><html:file property="importFile" styleId="importFile" size="60" maxlength="120" /></td> </tr> <tr> <td class="spacerCell"> </td> </tr> </table> </div> <table border="0" class="footerBar"> <tr> <td id="footerLeft"> <html:submit value=" OK " title=" OK " styleClass="button"> </html:submit> <span> <a class="buttonStyle" href="<%=request.getContextPath()%>/employees.do?method=load"> Cancel </a> </span> </td> <td id="footerRight" class="pagination"> </td> </tr> </table> 

上传CSV文件并单击“确定”后,将调用适当的操作类方法,并且我的url更改为-context path / importEmployee.do?method = save

该页面基本上包含导入统计信息,未处理记录的错误消息等。 该页面还具有确定和取消按钮。 相应的JSP部分如下。

 <html:form action="importEmployee?method=save" method="POST" styleId="importEmployee" enctype="multipart/form-data"> <table border="0" > <tr> <td id="leftEdge"><img src="<%= request.getContextPath()%>/images/new/edge_left.gif" width="30" 

height =“ 321” alt =“” />

  ..... some processing and then... <table border="0" class="footerBar"> <tr> <td id="footerLeft"> <span> <a class="buttonStyle" href="<%=request.getContextPath()%>/employees.do?method=load"> OK </a> </span> <input name="cancel" id="cancel" type="submit" class="button" value="Cancel" onclick="goBack(); return false;" /> </td> <td id="footerRight" class="pagination"> </td> </tr> </table> 

因此,如果单击第二页中的“取消”(上下文路径/importEmployee.do?method=save),则会返回到第一个URL页面,即上下文路径/importEmployee.do?method=load。 但是此部分在Firefox和Chrome浏览器中的行为有所不同。 在Chrome中,如果我在第二页中单击“取消”,则仍然可以在第一页中看到上载的文件名(第一个JSP中的隐藏属性是文件名)。 如果单击“确定”,则可以再次进行处理,就像在第一页上单击“确定”一样。 但是,当我在Firefox浏览器中运行应用程序时,如果在第二页中单击“取消”,则上载的文件名在第一页中显示“未选择文件”。 因此,要再次导入员工,我需要再次上传新的/相同的CSV文件。

即使我在Chrome中运行应用程序,我也不想在第二页中单击“取消”时在第一页中显示该文件。 是的,我要求文件名是隐藏属性。 这是因为取决于文件中的数据,将执行不同类型的处理,并且其中一些处理需要在另一页上接受用户的其他输入,而第三页进行处理。 因此,文件名应传递给表单,但我不希望用户再次上传文件。

但是,如果用户单击“取消”,则我不希望文件名保留在第一页中。 但是,这没有发生。

所以我有两个问题。 为什么Chrome和Firefox中的行为有所不同,有什么办法可以纠正它在chrome中的行为?

解决了。

工作中的人们说,取消按钮的行为是一种已知的行为。 单击Chrome中的“取消”后,再次看到文件名是可以的。 我们不应该在Mozilla中看到它。

很抱歉造成您的困惑,也感谢您回答我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM