Search code examples
javacharacter-encodingvelocity

VelocityEngineUtils.mergeTemplateIntoString falls with UTF-8 and spanish letters


After mergeTemplateIntoString, the spanish simbols like Ñ and ñ falls.

public String loadData (VelocityEngine velocityEngine, Map mParam) {

        String result;

        try {

            result = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "informesHtml/template.vm",
                mParam);

            return result;

        } catch (VelocityException e) {
            e.printStackTrace();
            return "";
        }
    }

The .vm template use UTF-8 and the DB WE8ISO8859P15. I've tried to change a velocityEngine format, but without success. The spring framework version is 4.3.9.


Solution

  • I just set text/html;charset=ISO-8859-1 in the .html file and now everything works fine.