阿拉伯语显示为??????在速度模板中

发布于 2024-10-06 03:59:53 字数 389 浏览 10 评论 0原文

大家好 我在发送电子邮件时使用速度模板 在模板中我有一些阿拉伯语文本

,发送电子邮件时,文本显示为????????? 我不知道为什么:

在发送电子邮件之前将编码设置为 utf-8:

VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,templateName, "UTF-8",newModel);

我尝试在虚拟机中添加字符集,但没有成功:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

有什么想法为什么会出现这样的问题吗?

Greetings all
i am using velocity templates in sending emails
and in the template i have some arabic texts

and when sending the email, the text appears like ??????????
i don't know why:

encoding is set to utf-8 before sending the email here:

VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,templateName, "UTF-8",newModel);

i tried to add the charset in the vm, but with no luck:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

any ideas why such problem occurs ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

哥,最终变帅啦 2024-10-13 03:59:54

我能够在从 Spring 应用程序发送的纯文本电子邮件中生成阿拉伯语文本 (সেসাসা)。文本在 GMail 和 Thunderbird 上正确显示。这是我的邮件发送逻辑:

public void send(String fromAddress, String fromName,
    String toAddress, String subject,
    String template, Map<String, Object> model) {
  MimeMessagePreparator preparator = new MimeMessagePreparator() {
    public void prepare(MimeMessage mimeMessage) throws Exception {
      MimeMessageHelper message = new MimeMessageHelper(
          mimeMessage, "UTF-8");
      message.setTo(toAddress);
      message.setFrom(new InternetAddress(fromAddress, fromName));
      message.setSubject(subject);
      message.setText(VelocityEngineUtils
          .mergeTemplateIntoString(velocityEngine, template, "UTF-8", 
              model));
    }
  };
  mailSender.send(preparator);
}

I was able to produce Arabic text (تجاوز سعة مكدس) on a plain-text email sent from a Spring app. The text displayed properly on GMail as well as Thunderbird. Here's my mail sending logic:

public void send(String fromAddress, String fromName,
    String toAddress, String subject,
    String template, Map<String, Object> model) {
  MimeMessagePreparator preparator = new MimeMessagePreparator() {
    public void prepare(MimeMessage mimeMessage) throws Exception {
      MimeMessageHelper message = new MimeMessageHelper(
          mimeMessage, "UTF-8");
      message.setTo(toAddress);
      message.setFrom(new InternetAddress(fromAddress, fromName));
      message.setSubject(subject);
      message.setText(VelocityEngineUtils
          .mergeTemplateIntoString(velocityEngine, template, "UTF-8", 
              model));
    }
  };
  mailSender.send(preparator);
}
扛刀软妹 2024-10-13 03:59:54

你有没有设置任何velocity.properties? (特别是 input.encoding 或 output.encoding)如果不是,请尝试将它们也设置为 UTF-8。

Do you have any velocity.properties set? (particularly input.encoding or output.encoding) If not, try setting those both to UTF-8 also.

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