简体   繁体   中英

Spring boot 2.1 / java 11 app not recognizing accentuated characters after migrating from Spring boot 2.0.5 / java 8

I have a Spring boot web app that used to work perfectly fine on java 8 and Spring boot 2.0.5. Now, when i visit any page and try to input data that has a É character for example, the character is saved as ? in the database and obviously retrieved as such. I have changed 0 code aside from adding the javax.json.bind-api dependency that is no longer built into the JRE. Is there some sort of global character encoding property that needs to be changed for non-standard characters to be recognized properly?

EDIT

This is the relevant bit of my JSP page :

<form:form method="POST" modelAttribute="medClass" class="form-style-7">
    <form:input path="name" id="name"/>
</form:form>

Controller code :

@RequestMapping(value = {"/newMedClass"}, method = RequestMethod.POST)
public String saveMedClass(@Valid MedClass medClass, BindingResult result, ModelMap model) 
{
    boolean hasCustomErrors = validate(result, medClass);
    if ((hasCustomErrors) || (result.hasErrors()))
    {
        setPermissions(model);

        return "medClassDataAccess";
    }
    medClassService.save(medClass);
    session.setAttribute("successMessage", "Successfully added med class \"" + medClass.getName() + "\"!");
    return "redirect:/medClasses/list";
}

When entering ÉÉÉÉ as the name for this entity (yes it's a string), the entity comes into the controller with ???? already and is therefore saved as such.

EDIT

I have this line at the top of every JSP :

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

Does this need to be changed?

Thanks

Changing the JSPs' charset to UTF-8 fixed it. How this worked perfectly before is a complete mystery...

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<meta http-equiv="Content-Type" content="text/html; charset=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