[英]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. 我有一个Spring Boot Web应用程序,该应用程序过去在Java 8和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.
除了添加不再内置到JRE中的javax.json.bind-api依赖项之外,我还更改了0代码。 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 : 这是我的JSP页面的相关内容:
<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 : 我在每个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. 将JSP的字符集更改为UTF-8可以解决此问题。 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">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.