spring mvc 中带有附件的电子邮件提交表单(添加、打开和删除)
如何创建允许用户指定的电子邮件表单:
- 至
- 主题
- 具有添加/打开/删除功能的附件
- 发送/取消按钮
我无法发送用户想要发送的文件的索引删除 ,例如,如果用户在电子邮件提交表单中附加了 file1、file2 和 file3,并且我在控制器中捕获了此信息作为键,值对,其中键是索引,值作为文件名。但用户可以在发送电子邮件之前删除任意文件,例如用户单击“file2”删除按钮。现在在控制器中,我想获取需要删除的文件的索引,但这是动态的,因为用户可以单击任何附加文件删除按钮。
我使用 spring 2.5 和 JSP/JSTL 作为视图组件。
请参阅示例电子邮件表格:(
To |_________________| Subject |________________| Attachments: [**ADD**]
**X** file1
**X** file2
**X** file3
单击“添加”按钮附加文件,单击“X”删除相应的附件,单击文件名查看/打开文件内容)
How can I create a email form which allows user to specify:
- To
- Subject
- Attachments with Add/Open/Remove facility
- send/cancel button
I'm having trouble to send the index of the file the user want to remove , for example if the user attached file1, file2, and file3 in the email submission form and I captured this info in the controller as key,value pair where key is index and value as file name. But the user is allowed to remove arbitrary file before sending the email, for example the user clicks 'file2' remove button. Now in the controller I want to grab the index of the file need to be removed, but this is dynamic since user can click any of the attached files remove button.
I'm using spring 2.5 with JSP/JSTL as view component.
Please see the sample email form:
To |_________________| Subject |________________| Attachments: [**ADD**]
**X** file1
**X** file2
**X** file3
(click the 'ADD' button to attach file, click 'X' to remove corresponding attached file,click on the file name to view/open the file contents)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果删除是在服务器端处理的,则可以将删除按钮实现为
If removing is handled at the server side, you can implement remove buttons as a
<button>
tag, wherename
is, say,fileToRemove
andvalue
is an index of the file. When user click that button, the form is submitted withfileToRemove=...
parameter:感谢 Axtavt,但我们使用 IE6 作为客户端浏览器,并且存在以下已知问题:
同时,按钮元素允许作者生成向服务器提交与按钮上显示的文本不匹配的数据的按钮。删除应提交到服务器 row_to_delete=1,但 Internet Explorer 将发送 row_to_delete=Delete。如果可以说服 IE 进行操作,那么这对于多语言网站也很有用 - 显示的文本可以针对每种语言进行翻译,但值可以保持不变,因此服务器端逻辑不需要检查翻译表。
但更糟糕的是,Internet Explorer 6 还有一个错误,它将所有元素视为成功的控件,并将其数据提交到服务器,即使它们没有被单击。这实际上使得使用多个按钮元素变得不可能。
Thanks Axtavt, but we are using IE6 as client browser and the following is known issue:
Meanwhile, the button element allows authors to produce buttons that submit data to the server that does not match the text displayed on the button. Delete should submit to the server row_to_delete=1 but Internet Explorer will send row_to_delete=Delete. If IE could be persuaded to behave, then this would also be useful for multilingual sites – the text displayed could be translated for each language, but the value could remain the same so the server side logic wouldn’t need to check the translation table.
It gets worse though, Internet Explorer 6 has a further bug where it will treat all elements as successful controls, and submit their data to the server, even if they were not clicked. This effectively makes using multiple button elements impossible.