spring mvc 中带有附件的电子邮件提交表单(添加、打开和删除)

发布于 2024-10-14 18:59:21 字数 562 浏览 0 评论 0原文

如何创建允许用户指定的电子邮件表单:

  • 主题
  • 具有添加/打开/删除功能的附件
  • 发送/取消按钮

我无法发送用户想要发送的文件的索引删除 ,例如,如果用户在电子邮件提交表单中附加了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与他有关 2024-10-21 18:59:21

如果删除是在服务器端处理的,则可以将删除按钮实现为

 <button name = "fileToRemove" value = "${file.id}">Remove</button>

If removing is handled at the server side, you can implement remove buttons as a <button> tag, where name is, say, fileToRemove and value is an index of the file. When user click that button, the form is submitted with fileToRemove=... parameter:

 <button name = "fileToRemove" value = "${file.id}">Remove</button>
心如荒岛 2024-10-21 18:59:21

感谢 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文