简体   繁体   中英

encoding between Axis2 and Apache Commons Email

I've got the following webservice method, which is called by REST:

public boolean sendMail(String text) {
    Email email = new SimpleEmail();
    email.setHostName(MAIL_SERVER);
    email.setSmtpPort(25);
    email.setAuthenticator(new DefaultAuthenticator(MAIL_USER, MAIL_PASSWORD));
    try {
        email.setFrom(MAIL_SENDER);
        email.setSubject(text);
        email.setMsg(text);
        email.addTo(MAIL_RECEIVER);
        email.send();
        return true;
    } catch (EmailException e) {
        return false;
    }
}

The request is like sendMail?text=aäoöuü which is encode with x-www-form-urlencoded to sendMail?text=a%E4o%F6u%FC

The content of the mail is a?o?u? .

Mail API is Apache Commons Email .

How can I get the right character encoding to the mail?

在应用URL编码之前,您应该使用UTF-8对参数进行编码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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