[英]Convert String to HTML Ready text for MAILTO: URL
I am writing a large Java Application in which I would like to include a "Send Email" button.我正在编写一个大型 Java 应用程序,我想在其中包含一个“发送电子邮件”按钮。 All it does is open a
mailto
url with the appropriate headers.它所做的只是打开一个带有适当标题的
mailto
url。
The only difficulty I am having is parsing the input strings so that they are formatted appropriately, for example: mailto:someone@somewhere.net?subject=This is the subject
needs to become mailto:someone@somewhere.net?subject=This%20is%20the%20subject
我遇到的唯一困难是解析输入字符串以便它们的格式正确,例如:
mailto:someone@somewhere.net?subject=This is the subject
needs to become mailto:someone@somewhere.net?subject=This%20is%20the%20subject
You can try URLEncoder , specifically the encode
method that can be found here .您可以尝试URLEncoder ,特别是可以在此处找到的
encode
方法。
You most likely need to "URLEncode" (translates the space characters (' ') to %20.您很可能需要“URLEncode”(将空格字符 (' ') 转换为 %20。
See this document: http://download.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html请参阅此文档: http://download.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.