Unicode chars and Spring JavaMailSenderImpl, no unicode chars under Linux!

前端 未结 3 1766
谎友^
谎友^ 2021-01-12 11:33

I\'m using Spring and JavaMailSenderImpl, a famous spring class to send emails. My emails contain a lot of unicode chars like èéàò or most notably the dreaded € symbol. My c

3条回答
  •  清酒与你
    2021-01-12 12:30

    In my case, I resolved the encoding problem by specifying JavaMailSenderImpl's defaultEncoding:

    mailSender = new JavaMailSenderImpl();
    ...
    mailSender.setDefaultEncoding("UTF-8");
    

    I believe you can also set the value in bean configuration:

    
        ...
        
    
    

提交回复
热议问题