Recently I experienced a problem, when I had CharacterEncodingFilter filter in my web.xml, but no encoding were done at all. I started to investigate this problem and find out, that few weeks ago I added additional filters on top of my web.xml, and , as a result, my CharacterEncodingFilter was placed on second or third position.Good news for me, I added integration test with ukrainian words, and my web service returned some incorrect characters.
After few minutes, I discovered, that If you want to have correct unicode data, then you need to place encoding filter at the top of all your filters. Thereafter, your filter will the first chain and you will be sure, that all other filters will work with correct unicode.
Nowadays, it’s very popular to have applications, that can somehow notificate people.We’re gonna use emails to send text and html mails to someone.Whar requirements do we need? Possibility to send simple text emails Posibility to send html emails. Of course, to send emails, we need to have some template engine. We will use handlebars for that. We will use Spring. Maven as build tool Java Mail package Handlebars template engine Greenmail for “mocking” email server. Structure We need to have four subpackages, exception package for having custom exceptions, model package for storing our model, sender package for main functionality and template package for storing template service. Your pom.xml should have similar structure So, let’s create Exception package Model package We created all required models and resources for further developing, so let’s start adding core functionality Template package Have ever you ever think about sending emails with html content ? Imagine, your application sends email with some pretty organized html page. Sound great. To do such things, of course, you need to have template engine. I prefer Handlebards template engine. [gist id=”60fd72b167cb6243c74f”] if you have template in your resources/templates folder with name template1.html, then you should call handlebars.compile(“template1”); in your code....